catalyst.passes.to_ppr

to_ppr(qnode)[source]

A quantum compilation pass that converts Clifford+T gates into Pauli Product Rotation (PPR) gates.

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).

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 Pauli product measurements and Pauli product rotations, check out the compilation hub.

The full list of supported gates and operations are qml.H, qml.S, qml.T, qml.X, qml.Y, qml.Z, qml.PauliRot, qml.adjoint(qml.PauliRot), qml.adjoint(qml.S), qml.adjoint(qml.T), qml.CNOT, and qml.measure.

Parameters:

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

Returns:

QNode

See also

commute_ppr(), merge_ppr_ppm(), ppr_to_ppm(), ppm_compilation(), reduce_t_depth(), decompose_arbitrary_ppr()

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 qml

@qml.qjit(capture=True)
@qml.transforms.to_ppr
@qml.qnode(qml.device("lightning.qubit", wires=2))
def circuit():
    qml.H(0)
    qml.CNOT([0, 1])
    m = qml.measure(0)
    qml.T(0)
    return qml.expval(qml.Z(0))
>>> circuit()
Array(-1., dtype=float64)
>>> print(qml.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.