mqt.qecc.circuit_synthesis.circuit_utils¶
Utility methods for circuits.
Functions¶
|
Relabels the qubits in a stim circuit based on the given mapping. |
|
Convert a Qiskit circuit to a Stim circuit. |
|
Move circuit instructions to the front and ignore TICKS. |
|
Compose and compact multiple stim circuits. |
|
Collect all layers that can be executed in parallel. |
|
Calculate the depth of a stim circuit. |
|
Remove all single-qubit gates from a stim circuit. |
|
Remove all SWAP gates from a stim circuit. |
|
Calculate the two-qubit gate depth of a stim circuit. |
|
Return a list of qubits that are not measured in circ. |
|
Return a list of qubits that are measured in circ. |
|
Compose two Stim circuits. |
|
Return the number of two-qubit gates in a stim circuit. |
Module Contents¶
- relabel_qubits(circ: stim.Circuit, qubit_mapping: dict[int, int] | int) stim.Circuit[source]¶
Relabels the qubits in a stim circuit based on the given mapping.
- Parameters:
circ – The original stim circuit.
qubit_mapping – Either a dictionary mapping original qubit indices to new qubit indices or a constant offset to add to all qubit indices.
- Returns:
A new stim circuit with qubits relabeled.
- qiskit_to_stim_circuit(qc: QuantumCircuit) stim.Circuit[source]¶
Convert a Qiskit circuit to a Stim circuit.
- compact_stim_circuit(circ: stim.Circuit, scheduling_method: str = 'asap') stim.Circuit[source]¶
Move circuit instructions to the front and ignore TICKS.
- Parameters:
circ – stim circuit to compact
scheduling_method – Either “asap” (as soon as possible) or “alap” (as late as possible).
- Returns:
A compacted stim circuit.
- compose_compact_stim_circuits(circs: list[stim.Circuit], align: str = 'start') stim.Circuit[source]¶
Compose and compact multiple stim circuits.
- Parameters:
circs – List of stim circuits to compose and compact.
align – Either “start” (align at the start) or “end” (align at the end).
- Returns:
A composed and compacted stim circuit.
- collect_circuit_layers(circ: stim.Circuit, scheduling_method: str = 'asap') list[stim.Circuit][source]¶
Collect all layers that can be executed in parallel.
- Parameters:
circ – Stim circuit to process.
scheduling_method – Either “asap” (as soon as possible) or “alap” (as late as possible).
- Returns:
list of circuit layers. All instructions in one layer can be executed in parallel. It holds that circ=sum(collect_circuit_layers(circ)).
- depth(circ: stim.Circuit) int[source]¶
Calculate the depth of a stim circuit.
- Parameters:
circ – The stim circuit to analyze.
- Returns:
The depth of the circuit.
- remove_single_qubit_gates(circ: stim.Circuit) stim.Circuit[source]¶
Remove all single-qubit gates from a stim circuit.
- Parameters:
circ – The stim circuit to filter.
- Returns:
A new stim circuit with single-qubit gates removed.
- remove_swap_gates(circ: stim.Circuit) stim.Circuit[source]¶
Remove all SWAP gates from a stim circuit.
- Parameters:
circ – The stim circuit to filter.
- Returns:
A new stim circuit with SWAP gates removed.
- two_qubit_gate_depth(circ: stim.Circuit, *, count_swaps: bool = False) int[source]¶
Calculate the two-qubit gate depth of a stim circuit.
- Parameters:
circ – The stim circuit to analyse.
count_swaps – If
True, SWAP gates are included in the depth calculation. Defaults toFalse.
- Returns:
The two-qubit gate depth of the circuit.
- unmeasured_qubits(circ: stim.Circuit) list[int][source]¶
Return a list of qubits that are not measured in circ.
- measured_qubits(circ: stim.Circuit) list[int][source]¶
Return a list of qubits that are measured in circ.
The qubits are in the ordered according to when they are measured.
- compose_circuits(circ1: stim.Circuit, circ2: stim.Circuit, wiring: dict[int, int] | None = None) tuple[stim.Circuit, dict[int, int], dict[int, int]][source]¶
Compose two Stim circuits.
The circuits are composed only along the qubits that are connected by the wiring dict. All other qubits are assumed to be unconnected. If wire is None, then the circuits are simply vertically stacked.
- Parameters:
circ1 – The first stim circuit.
circ2 – The second stim circuit.
wiring – Optional dict mapping outputs of circ1 to inputs of circ2.
- Returns:
mapping1: Maps qubits of circ1 to the composed circuit.
mapping2: Maps qubits of circ2 to the composed circuit.
- Return type:
A tuple containing the composed stim circuit and two mappings
- num_two_qubit_gates(circ: stim.Circuit, *, count_swaps: bool = False) int[source]¶
Return the number of two-qubit gates in a stim circuit.
- Parameters:
circ – The stim circuit to analyse.
count_swaps – If
True, SWAP gates are counted as two-qubit gates. Defaults toFalse.
- Returns:
The number of two-qubit gates.