Loading [MathJax]/jax/output/CommonHTML/jax.js

catalyst.passes.commute_ppr

commute_ppr(qnode)[source]

Specify that the MLIR compiler pass for commuting Clifford Pauli Product Rotation (PPR) gates, exp(iPπ4), past non-Clifford PPRs gates, exp(iPπ8) will be applied, where P is a Pauli word.

For more information regarding to PPM, see here <https://pennylane.ai/compilation/pauli-product-measurement>

Note

The commute_ppr compilation pass requires that to_ppr() be applied first.

Parameters

fn (QNode) – QNode to apply the pass to.

Returns

~.QNode

Example

The commute_ppr pass must be used in conjunction with to_ppr() to first convert gates into PPRs. In this example, the Clifford+T gates in the circuit will be converted into PPRs first, then the Clifford PPRs will be commuted past the non-Clifford PPR.

import pennylane as qml
from catalyst import qjit, measure

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

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

print(circuit.mlir_opt)

Example MLIR Representation:

. . .
%2 = qec.ppr ["X"](8) %1 : !quantum.bit
%3 = qec.ppr ["Z"](4) %2 : !quantum.bit
%4 = qec.ppr ["X"](4) %3 : !quantum.bit
%5 = qec.ppr ["Z"](4) %4 : !quantum.bit
%mres, %out_qubits = qec.ppm ["Z"] %5 : !quantum.bit
. . .