catalyst.passes.to_ppr

to_ppr(qnode)

A quantum compilation pass that converts Clifford+T gates into Pauli-product rotations (PPR) and measurements (PPM). Pauli-based operations are also allowed in the input.

Note

This transform requires decorating the workflow with @qjit. In addition, the circuits generated by this pass are currently executable on lightning.qubit or null.qubit (for mock-execution).

Pauli gates are converted to \(\exp(-{iP\tfrac{\pi}{2}})\), Clifford gates to \(\exp(-{iP\tfrac{\pi}{4}})\), and non-Clifford gates to \(\exp(-{iP\tfrac{\pi}{8}})\), where \(P\) is a Pauli word.

For more information on Pauli product measurements and Pauli product rotations, check out the compilation hub.

The full list of supported gates and operations are qp.H, qp.S, qp.T, qp.X, qp.Y, qp.Z, qp.CNOT, qp.RX, qp.RY, qp.RZ, qp.IsingXX, qp.IsingYY, qp.IsingZZ, qp.MultiRZ, qp.PauliRot, and adjoint versions thereof, as well as qp.measure and qp.pauli_measure.

Parameters:

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

Returns:

QNode

Note

For better compatibility with other PennyLane functionality, ensure that PennyLane program capture is enabled with @qjit(capture=True).

Example

The to_ppr compilation pass can be applied as a decorator on a QNode:

import pennylane as qp

@qp.qjit(capture=True)
@qp.transforms.to_ppr
@qp.qnode(qp.device("lightning.qubit", wires=2))
def circuit():
    qp.H(0)
    qp.CNOT([0, 1])
    m = qp.measure(0)
    qp.T(0)
    return qp.expval(qp.Z(0))
>>> circuit()
Array(-1., dtype=float64)
>>> print(qp.specs(circuit, level=1)())
Device: lightning.qubit
Device wires: 2
Shots: Shots(total=None)
Level: to-ppr

Wire allocations: 2
Total gates: 11
Gate counts:
- GlobalPhase: 3
- PPR-pi/4-w1: 5
- PPR-pi/4-w2: 1
- PPM-w1: 1
- PPR-pi/8-w1: 1
Measurements:
- expval(PauliZ): 1
Depth: Not computed

In the above output, PPR-theta-w<int> denotes the type of PPR present in the circuit, where theta is the PPR angle (\(\theta\)) and w<int> denotes the PPR weight (the number of qubits it acts on, or the length of the Pauli word). PPM-w<int> follows the same convention. Note that the mid-circuit measurement (pennylane.measure()) in the circuit has been converted to a Pauli product measurement (PPM), as well.