catalyst.passes.to_ppr

to_ppr(qnode)[source]

Specify that the MLIR compiler pass for converting clifford+T gates into Pauli Product Rotation (PPR) gates will be applied.

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 circuit that generated from this pass are currently only not executable in any backend. This pass is only for analysis and potential future execution when a suitable backend is available.

The full list of supported gates are as follows: qml.H, qml.S, qml.T, qml.CNOT, qml.measure()

Parameters

fn (QNode) – QNode to apply the pass to

Returns

~.QNode

Example

In this example the Clifford+T gates will be converted into PPRs.

import pennylane as qml
from catalyst import qjit, measure

ppm_passes = [("PPM", ["to_ppr"])]

@qjit(pipelines=ppm_passes, keep_intermediate=True, target="mlir")
@qml.qnode(qml.device("null.qubit", wires=2))
def circuit():
    qml.H(0)
    qml.CNOT([0, 1])
    qml.T(0)
    return measure(1)

print(circuit.mlir_opt)

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
%c_3 = stablehlo.constant dense<1> : tensor<i64>
%extracted_4 = tensor.extract %c_3[] : tensor<i64>
%5 = quantum.extract %0[%extracted_4] : !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
%mres, %out_qubits = qec.ppm ["Z"] %8 : !quantum.bit
. . .