qml.transforms.to_ppr

to_ppr(tape)[source]

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

Note

This transform requires decorating the workflow with @qml.qjit. In addition, the circuits generated by this pass are currently not executable on any backend. This pass is only for Pauli-based-computation analysis with the null.qubit device and potential future execution when a suitable backend is available.

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

Note

For better compatibility with other PennyLane functionality, ensure that PennyLane program capture is enabled with pennylane.capture.enable().

Example

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

import pennylane as qml

qml.capture.enable()

@qml.qjit(target="mlir")
@qml.transforms.to_ppr
@qml.qnode(qml.device("null.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))

To inspect programs compiled with to_ppr via specs(), ensure that target="mlir" is given in the qjit decorator.

>>> print(qml.specs(circuit, level=2)())
Device: null.qubit
Device wires: 2
Shots: Shots(total=None)
Level: 2

Resource specifications:
    Total wire allocations: 2
    Total gates: 8
    Circuit depth: Not computed

Gate types:
    PPR-pi/4: 6
    PPM: 1
    PPR-pi/8: 1

Measurements:
    expval(PauliZ): 1

In the above output, PPR-theta denotes the type of PPR present in the circuit, where theta is the PPR angle (\(\theta\)). Note that the mid-circuit measurement (pennylane.measure()) in the circuit has been converted to a Pauli product measurement (PPM), as well.