qml.transforms.ppr_to_ppm

ppr_to_ppm(tape=None, *, decompose_method='pauli-corrected', avoid_y_measure=False)[source]

A quantum compilation pass that decomposes Pauli product rotations (PPRs), \(P(\theta) = \exp(-iP\theta)\), into Pauli product measurements (PPMs).

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.

Lastly, the pennylane.transforms.to_ppr() transform must be applied before ppr_to_ppm.

This pass is used to decompose both non-Clifford and Clifford PPRs into PPMs. The non-Clifford PPRs (\(\theta = \tfrac{\pi}{8}\)) are decomposed first, then Clifford PPRs (\(\theta = \tfrac{\pi}{4}\)) are decomposed.

For more information on PPRs and PPMs, check out the Compilation Hub.

Parameters:
  • qnode (QNode) – QNode to apply the pass to.

  • decompose_method (str) – The method to use for decomposing non-Clifford PPRs. Options are "pauli-corrected", "auto-corrected", and "clifford-corrected". Defaults to "pauli-corrected". "pauli-corrected" uses a reactive measurement for correction that is based on Figure 13 in arXiv:2211.15465. "auto-corrected" uses an additional measurement for correction that is based on Figure 7 in A Game of Surface Codes, and "clifford-corrected" uses a Clifford rotation for correction that is based on Figure 17(b) in A Game of Surface Codes.

  • avoid_y_measure (bool) – Rather than performing a Pauli-Y measurement for Clifford rotations (sometimes more costly), a \(Y\) state (\(Y\vert 0 \rangle\)) is used instead (requires \(Y\)-state preparation). This is currently only supported when using the "clifford-corrected" and "pauli-corrected" decomposition methods. Defaults to False.

Returns:

QNode

Note

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

Example

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

import pennylane as qml
from functools import partial
import jax.numpy as jnp

qml.capture.enable()

@qml.qjit(target="mlir")
@qml.transforms.ppr_to_ppm(decompose_method="auto-corrected")
@qml.transforms.to_ppr
@qml.qnode(qml.device("null.qubit", wires=2))
def circuit():
    # equivalent to a Hadamard gate
    qml.PauliRot(jnp.pi / 2, pauli_word="Z", wires=0)
    qml.PauliRot(jnp.pi / 2, pauli_word="X", wires=0)
    qml.PauliRot(jnp.pi / 2, pauli_word="Z", wires=0)

    # equivalent to a CNOT gate
    qml.PauliRot(jnp.pi / 2, pauli_word="ZX", wires=[0, 1])
    qml.PauliRot(-jnp.pi / 2, pauli_word="Z", wires=[0])
    qml.PauliRot(-jnp.pi / 2, pauli_word="X", wires=[1])

    # equivalent to a T gate
    qml.PauliRot(jnp.pi / 4, pauli_word="Z", wires=0)

    return qml.expval(qml.Z(0))

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

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

Resource specifications:
Total wire allocations: 9
Total gates: 24
Circuit depth: Not computed

Gate types:
    PPM: 16
    PPR-pi/2: 7
    qec.fabricate: 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 \(\theta = \tfrac{\pi}{2}\) PPRs correspond to Pauli operators (\(P(\tfrac{\pi}{2}) = \exp(-iP\tfrac{\pi}{2}) = P\)). Pauli operators can be commuted to the end of the circuit and absorbed into terminal measurements.