catalyst.passes.ppm_specs

ppm_specs(fn)[source]

This function returns following Pauli product rotation (PPR) and Pauli product measurement (PPM) specs in a dictionary:

  • Pi/4 PPR (count the number of clifford PPRs)

  • Pi/8 PPR (count the number of non-clifford PPRs)

  • Pi/2 PPR (count the number of classical PPRs)

  • Max weight for pi/8 PPRs

  • Max weight for pi/4 PPRs

  • Max weight for pi/2 PPRs

  • Number of logical qubits

  • Number of PPMs

Note

It is recommended to use pennylane.specs() instead of ppm_specs to retrieve resource counts of PPR-PPM workflows.

When there is control flow, this function can count the above statistics inside for loops with a statically known number of iterations. For all other cases, including dynamically sized for loops, and any conditionals and while loops, this pass exits with failure.

Parameters:

fn (QJIT) – qjit-decorated function for which ppm_specs need to be printed.

Returns:

A Python dictionary containing PPM specs of all functions in fn.

Return type:

dict

Example

import pennylane as qml
from catalyst import qjit, measure, for_loop
from catalyst.passes import ppm_specs, ppm_compilation

pipe = [("pipe", ["quantum-compilation-stage"])]
device = qml.device("lightning.qubit", wires=2)

@qjit(pipelines=pipe, target="mlir")
@ppm_compilation
@qml.qnode(device)
def circuit():
    qml.H(0)
    qml.CNOT([0,1])
    @for_loop(0,10,1)
    def loop(i):
        qml.T(1)
    loop()
    return measure(0), measure(1)

ppm_specs = ppm_specs(circuit)
print(ppm_specs)

Example PPM Specs:

. . .
{
    'circuit_0': {
                'max_weight_pi2': 2,
                'logical_qubits': 2,
                'num_of_ppm': 44,
                'pi2_ppr': 16
            },
}
. . .