catalyst.passes.merge_ppr_ppm

merge_ppr_ppm(qnode=None, *, max_pauli_size=0)[source]

A quantum compilation pass that absorbs Clifford Pauli product rotation (PPR) operations, \(\exp{-iP\tfrac{\pi}{4}}\), into the final Pauli product measurements (PPMs).

Note

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

Secondly, the merge_ppr_ppm transform does not currently affect terminal measurements. So, for accurate results, it is recommended to return nothing (i.e., a blank return statement) from the QNode.

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

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

Parameters:
  • fn (QNode) – QNode to apply the pass to

  • max_pauli_size (int) – The maximum size of Pauli strings resulting from merging. If a merge results in a PPM that acts on more than max_pauli_size qubits, that merge will not be performed. The default value is 0 (no limit).

Returns:

QNode

See also

to_ppr(), commute_ppr(), 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 merge_ppr_ppm compilation pass can be applied as a decorator on a QNode:

import pennylane as qml
import jax.numpy as jnp

@qml.qjit(capture=True)
@qml.transforms.merge_ppr_ppm(max_pauli_size=2)
@qml.transforms.to_ppr
@qml.qnode(qml.device("lightning.qubit", wires=2))
def circuit():
    qml.PauliRot(jnp.pi / 2, pauli_word="Z", wires=0)
    qml.PauliRot(jnp.pi / 2, pauli_word="X", wires=1)

    ppm = qml.pauli_measure(pauli_word="ZX", wires=[0, 1])

    return qml.probs()
>>> circuit()
Array([0.5, 0.5, 0. , 0. ], dtype=float64)
>>> print(qml.specs(circuit, level=2)())
Device: lightning.qubit
Device wires: 2
Shots: Shots(total=None)
Level: merge-ppr-ppm

Wire allocations: 2
Total gates: 3
Gate counts:
- PPM-w2: 1
- PPR-pi/4-w1: 2
Measurements:
- probs(all wires): 1
Depth: Not computed

If a merging resulted in a PPM acting on more than max_pauli_size qubits, that merging operation would be skipped. In the above output, PPM-w<int> denotes the PPM weight (the number of qubits it acts on, or the length of the Pauli word).