catalyst.passes.to_ppr¶
- to_ppr(qnode)[source]¶
A quantum compilation pass that converts Clifford+T gates into Pauli Product Rotation (PPR) gates.
Note
For improved integration with the PennyLane frontend, including inspectability with
pennylane.specs(), please usepennylane.transforms.to_ppr().Clifford gates are defined as \(\exp(-{iP\tfrac{\pi}{4}})\), where \(P\) is a Pauli word. Non-Clifford gates are defined as \(\exp(-{iP\tfrac{\pi}{8}})\).
For more information on the PPM compilation pass, check out the compilation hub.
Note
The circuits that generated from this pass are currently not executable on any backend. This pass is only for analysis with the
null.qubitdevice and potential future execution when a suitable backend is available.The full list of supported gates and operations are
qml.H,qml.S,qml.T,qml.X,qml.Y,qml.Z,qml.adjoint(qml.S),qml.adjoint(qml.T),qml.CNOT,qml.PauliRot, andcatalyst.measure.- Parameters:
fn (QNode) – QNode to apply the pass to
- Returns:
Example
In this example the Clifford+T gates will be converted into PPRs.
import pennylane as qml import catalyst p = [("my_pipe", ["quantum-compilation-stage"])] @qml.qjit(pipelines=p, target="mlir") @catalyst.passes.to_ppr @qml.qnode(qml.device("null.qubit", wires=2)) def circuit(): qml.H(0) qml.CNOT([0, 1]) qml.T(0) return print(circuit.mlir_opt)
Because Catalyst does not currently support execution of Pauli-based computation operations, we must halt the pipeline after
quantum-compilation-stage. This ensures that only the quantum passes will be applied to the initial MLIR, without attempting to further compile for execution.Example MLIR Representation:
. . . %2 = qec.ppr ["Z"](4) %1 : !quantum.bit %3 = qec.ppr ["X"](4) %2 : !quantum.bit %4 = qec.ppr ["Z"](4) %3 : !quantum.bit %5 = quantum.extract %0[ 1] : !quantum.reg -> !quantum.bit %6:2 = qec.ppr ["Z", "X"](4) %4, %5 : !quantum.bit, !quantum.bit %7 = qec.ppr ["Z"](-4) %6#0 : !quantum.bit %8 = qec.ppr ["X"](-4) %6#1 : !quantum.bit %9 = qec.ppr ["Z"](8) %7 : !quantum.bit . . .