mqt.qecc.code_switching.compilation_utils¶
Utilities for quantum circuit compilation: random circuit generation, code-switch analysis, node parsing, and placeholder insertion.
Functions¶
|
Count how many code switches are needed for a circuit assuming. |
|
Return a new circuit with 'switch' placeholders inserted between global DAG layers. |
Module Contents¶
- naive_switching(circuit: qiskit.QuantumCircuit) tuple[int, list[str | None]][source]¶
Count how many code switches are needed for a circuit assuming.
Code A supports H, CNOT
Code B supports CNOT, T
CNOT can only occur between qubits in the same code
Each qubit starts in the code of its first gate.
- Returns:
total number of code switches dict: final code assignment per qubit
- Return type:
- insert_switch_placeholders(circuit: qiskit.QuantumCircuit, switch_positions: list[tuple[int, int]], placeholder_depth: int = 1) qiskit.QuantumCircuit[source]¶
Return a new circuit with ‘switch’ placeholders inserted between global DAG layers.
This function inserts placeholders after the entire global layer with index layer_index (i.e., between layer layer_index and the next). Placeholders are placed on the requested qubit regardless of whether that qubit was active in that layer.
Parameters¶
- circuitQuantumCircuit
The original circuit to augment.
- switch_positionsList[Tuple[int, int]]
List of (qubit_index, layer_index). layer_index refers to the index from list(circuit_to_dag(circuit).layers()). A placeholder for (q, k) will be inserted after global layer k.
- placeholder_depthint, optional
Virtual depth (single-qubit layers) the placeholder should represent.
- expand_placeholderbool, optional
If True, expand each placeholder into placeholder_depth calls to QuantumCircuit.id(qubit) so that QuantumCircuit.depth() increases. If False, append a single SwitchGate marker (informational only).
Returns:¶
- QuantumCircuit
New circuit with placeholders inserted.