qml.transforms.merge_ppr_ppm¶
- merge_ppr_ppm(tape=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 not executable on any backend. This pass is only for Pauli-based-computation analysis with thenull.qubitdevice and potential future execution when a suitable backend is available.Secondly, the
merge_ppr_ppmtransform does not currently affect terminal measurements. So, for accurate results, it is recommended to return nothing (i.e., a blankreturnstatement) from the QNode.Lastly, the
pennylane.transforms.to_ppr()transform must be applied beforemerge_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_sizequbits, that merge will not be performed. The default value is0(no limit).
- Returns:
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
pennylane.capture.enable().Example
The
merge_ppr_ppmcompilation pass can be applied as a decorator on a QNode:import pennylane as qml import jax.numpy as jnp qml.capture.enable() @qml.qjit(target="mlir") @qml.transforms.merge_ppr_ppm(max_pauli_size=2) @qml.transforms.to_ppr @qml.qnode(qml.device("null.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
To inspect programs compiled with
merge_ppr_ppmviaspecs(), ensure thattarget="mlir"is given in theqjitdecorator.>>> print(qml.specs(circuit, level=3)()) Device: null.qubit Device wires: 2 Shots: Shots(total=None) Level: 3 Resource specifications: Total wire allocations: 2 Total gates: 1 Circuit depth: Not computed Gate types: PPM: 1 Measurements: No measurements.
If a merging resulted in a PPM acting on more than
max_pauli_sizequbits, that merging operation would be skipped.