graphix.circ_ext.compilation module¶
Compilation passes to transform the result of the circuit extraction algorithm into a quantum circuit.
- er_to_circuit(er: ExtractionResult, pexp_cp: Callable[[PauliExponentialDAG, Circuit], None] | None = None, cm_cp: Callable[[CliffordMap, Circuit], None] | None = None) Circuit[source]¶
Convert a circuit extraction result into a quantum circuit representation.
This method synthesizes a circuit by sequentially applying the Clifford map and the Pauli exponential DAG (Directed Acyclic Graph) in the extraction result. It performs a validation check to ensure that the output nodes of both components are identical.
- Parameters:
er (ExtractionResult) – The result of the extraction process, containing both the
clifford_mapand thepexp_dag.pexp_cp (Callable[[PauliExponentialDAG, Circuit], None] | None) – Compilation pass to synthesize a Pauli exponential DAG. If
None(default),pexp_ladder_pass()is employed.cm_cp (Callable[[CliffordMap, Circuit], None] | None) – Compilation pass to synthesize a Clifford map. If
None(default),cm_berg_pass()is employed. This pass only handles unitaries so far (Clifford maps with the same number of input and output nodes).
- Returns:
A quantum circuit that combines the Clifford map operations followed by the Pauli exponential operations.
- Return type:
- Raises:
ValueError – If the output nodes of
er.pexp_dagander.clifford_mapdo not match, indicating an incompatible extraction result.
- pexp_ladder_pass(pexp_dag: PauliExponentialDAG, circuit: Circuit) None[source]¶
Add a Pauli exponential DAG to a circuit by using a ladder decomposition.
The input circuit is modified in-place.
- Parameters:
pexp_dag (PauliExponentialDAG) – The Pauli exponential rotation to be added to the circuit. Its Pauli strings are defined on qubit indices.
circuit (Circuit) – The circuit to which the operation is added. The input circuit is assumed to be compatible with
pexp_dag.output_nodes.
Notes
Pauli exponentials in the DAG are compiled sequentially following an arbitrary total order compatible with the DAG. Each Pauli exponential is decomposed into a sequence of basis changes, CNOT gates, and a single \(R_Z\) rotation:
\[R_Z(\phi) = \exp \left(-i \frac{\phi}{2} Z \right),\]with effective angle \(\phi = -2\alpha\), where \(\alpha\) is the angle encoded in
self.angle. Basis changes map \(X\) and \(Y\) operators to the \(Z\) basis before entangling the qubits in a CNOT ladder.Gate set: H, CNOT, RZ, RY
See https://quantumcomputing.stackexchange.com/questions/5567/circuit-construction-for-hamiltonian-simulation/11373#11373 for additional information.
- cm_berg_pass(clifford_map: CliffordMap, circuit: Circuit) None[source]¶
Add a Clifford map to a circuit by using an adaptation of van den Berg’s sweeping algorithm introduced in Ref. [1].
The input circuit is modified in-place.
- Parameters:
clifford_map (CliffordMap) – The Clifford map to be transpiled.
circuit (Circuit) – The circuit to which the operation is added. The input circuit is assumed to be compatible with
CliffordMap.input_nodesandCliffordMap.output_nodes.
- Raises:
NotImplementedError – If
len(clifford_map.input_nodes) != len(clifford_map.output_nodes).AssertionError – If an unexpected pivot position is encountered during Step 4.
Notes
This pass only handles unitaries so far (Clifford maps with the same number of input and output nodes).
Gate set: H, SDG, CNOT, SWAP, X, Y, Z
This function converts a
CliffordMapinto a sequence of quantum gate instructions by operating on its binary tableau representation. The synthesis proceeds qubit-by-qubit, applying a sequence of local transformations (H, S, CNOT, and SWAP gates) to reduce the tableau into a canonical form. The resulting sequence represents the adjoint of the input Clifford map, therefore it’s appended in reverse order (and exchanging S by Sdagger) to the providedCircuit.The synthesis applies a series of steps on every qubit subtableau:
\[\]- T_q = begin{pmatrix}
XX & XZ \ ZX & ZZ
end{pmatrix}
Clear elements in the XZ-block by applying single-qubit gates (H or S).
Use CNOT gates to reduce the XX block to a single pivot column.
Apply a SWAP gate to bring the pivot to the diagonal if necessary.
4. Ensure the ZX and ZZ blocks of the tableau have the correct canonical form by redoing steps 1. and 2.
After processing all qubits, a final sign correction step applies Pauli gates (X, Y, Z) to fix phase bits in the tableau.
The generated instructions are accumulated during the forward pass and then appended to the circuit in reverse order to yield the correct overall transformation.
For the mapping between tableau updates and Clifford gates (H, S, CNOT) see [2].
References
[1] Van Den Berg, 2021. A simple method for sampling random Clifford operators (arxiv:2008.06011). [2] Aaronson, Gottesman, (2004). Improved Simulation of Stabilizer Circuits (arXiv:quant-ph/0406196).