catalyst.passes.get_ppm_specs

get_ppm_specs(fn)[source]
This function returns following 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

PPM Specs are returned after the last PPM compilation pass is run.

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:

Returns a Python dictionary containing PPM specs of all functions in QJIT

Return type:

dict

Example

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

pipe = [("pipe", ["enforce-runtime-invariants-pipeline"])]
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 = get_ppm_specs(circuit)
print(ppm_specs)

Example PPM Specs:

. . .
{
    'circuit_0': {
                'max_weight_pi2': 2,
                'num_logical_qubits': 2,
                'num_of_ppm': 44,
                'num_pi2_gates': 16
            },
}
. . .