PennyLane Python Frontend

Module: catalyst

This package contains the Catalyst Python interface.

Functions

qjit([fn, autograph, autograph_include, ...])

A just-in-time decorator for PennyLane and JAX programs using Catalyst.

debug_assert(condition, error)

Asserts at runtime that the given condition holds, raising an error with the provided message if it does not.

pipeline(pass_pipeline)

Configures the Catalyst MLIR pass pipeline for quantum circuit transformations for a QNode within a qjit-compiled program.

accelerate([func, dev])

Execute a jax.jit accelerated function on classical accelerators such as GPUs from within a qjit-compiled function.

pure_callback(callback_fn[, result_type])

Execute and return the results of a functionally pure Python function from within a qjit-compiled function.

cond(pred)

A qjit() compatible decorator for if-else conditionals in PennyLane/Catalyst.

for_loop(lower_bound, upper_bound, step[, ...])

A qjit() compatible for-loop decorator for PennyLane/Catalyst.

while_loop(cond_fn[, allow_array_resizing])

A qjit() compatible while-loop decorator for PennyLane/Catalyst.

ctrl(f, control[, control_values, work_wires])

Create a method that applies a controlled version of the provided op.

grad([fn, method, h, argnums])

A qjit() compatible gradient transformation for PennyLane/Catalyst.

value_and_grad([fn, method, h, argnums])

A qjit()-compatible transformation for returning the result and gradient of a function.

jacobian([fn, method, h, argnums])

A qjit() compatible Jacobian transformation for PennyLane/Catalyst.

vjp(f, params, cotangents, *[, method, h, ...])

A qjit() compatible Vector-Jacobian product for PennyLane/Catalyst.

jvp(f, params, tangents, *[, method, h, argnums])

A qjit() compatible Jacobian-vector product for PennyLane/Catalyst.

mitigate_with_zne([fn, extrapolate, ...])

A qjit() compatible error mitigation of an input circuit using zero-noise extrapolation.

vmap([fn, in_axes, out_axes, axis_size])

A qjit() compatible vectorizing map.

measure(wires[, reset, postselect])

A qjit() compatible mid-circuit measurement on 1 qubit for PennyLane/Catalyst.

adjoint(f[, lazy])

A qjit() compatible adjoint transformer for PennyLane/Catalyst.

ctrl(f, control[, control_values, work_wires])

Create a method that applies a controlled version of the provided op.

autograph_source(fn)

Utility function to retrieve the source code of a function converted by AutoGraph.

run_autograph(fn, *modules)

Decorator that converts the given function into graph form.

Classes

QJIT(fn, compile_options)

Class representing a just-in-time compiled hybrid quantum-classical function.

AutoGraphError

Errors related to Catalyst's AutoGraph module.

CompileError

Error encountered in the compilation phase.

DifferentiableCompileError

An error indicating an invalid differentiation configuration.

CompileOptions(verbose, logfile, target, ...)

Generic compilation options, for which reasonable default values exist.

Variables

autograph_ignore_fallbacks

Specify whether AutoGraph should avoid raising warnings when conversion fails and control flow instead falls back to being interpreted by Python at compile-time.

autograph_strict_conversion

Specify whether AutoGraph should raise exceptions when conversion fails, rather than falling back to interpreting control flow by Python at compile-time.

disable_autograph

Context decorator that disables AutoGraph for the given function/context.

Module: catalyst.debug

Catalyst’s debug module contains functions useful for user program debugging.

Functions

callback(callback_fn)

Execute a Python function with no return value and potential side effects from within a qjit-compiled function.

print(fmt, *args, **kwargs)

A qjit() compatible print function for printing values at runtime.

print_memref(x)

A qjit() compatible print function for printing numeric values at runtime with memref information.

get_compilation_stage(fn, stage)

Returns the intermediate representation of one of the recorded compilation stages for a JIT-compiled function.

get_compilation_stages_groups(options)

Returns a list of tuples.

get_cmain(fn, *args)

Return a C program that calls a jitted function with the provided arguments.

instrumentation(session_name[, filename, ...])

Instrumentation session to output information on wall time, CPU time, and intermediate program size of a program during compilation and execution.

replace_ir(fn, stage, new_ir)

Replace the IR at any compilation stage that will be used the next time the function runs.

compile_executable(fn, *args)

Generate an executable binary for the native host architecture from a qjit() decorated function with provided arguments.

Module: catalyst.passes

This module contains Python decorators for enabling and configuring individual Catalyst MLIR compiler passes.

Note

Unlike PennyLane circuit transformations, the QNode itself will not be changed or transformed by applying these decorators.

As a result, circuit inspection tools such as draw() will continue to display the circuit as written in Python.

Instead, these compiler passes are applied at the MLIR level, which occurs outside of Python during compile time. To inspect the compiled MLIR from Catalyst, use get_compilation_stage() with stage="QuantumCompilationPass".

Functions

apply_pass(pass_name, *flags, **valued_options)

Applies a single pass to the qnode

apply_pass_plugin(plugin_name, pass_name, ...)

Applies a pass plugin

cancel_inverses([qnode])

Specify that the -removed-chained-self-inverse MLIR compiler pass for cancelling two neighbouring self-inverse gates should be applied to the decorated QNode during qjit() compilation.

dictionary_to_tuple_of_passes(pass_pipeline)

Convert dictionary of passes into tuple of passes

entry_points(**params)

Return EntryPoint objects for all installed packages.

ions_decomposition([qnode])

Apply decomposition pass at the MLIR level

merge_rotations([qnode])

Specify that the -merge-rotations MLIR compiler pass for merging roations (peephole) will be applied.

pipeline(pass_pipeline)

Configures the Catalyst MLIR pass pipeline for quantum circuit transformations for a QNode within a qjit-compiled program.

Classes

EvaluationContext(mode)

Utility context managing class keeping track of various modes of Catalyst executions.

Pass(name, *options, **valued_options)

Class intended to hold options for passes

PassPlugin(path, name, *options, ...)

Class intended to hold options for pass plugins

Path(*args, **kwargs)

PurePath subclass that can make system calls.

PipelineDict

alias of dict[str, dict[str, str]]

Module: catalyst.third_party.cuda

This module contains a CudaQDevice and the qjit entry point.

Functions

cudaqjit([fn])

A decorator for compiling PennyLane and JAX programs using CUDA Quantum.

Classes

BaseCudaInstructionSet([shots, wires])

Base instruction set for CUDA-Quantum devices

SoftwareQQPP([shots, wires])

The SoftwareQ Q++ statevector simulator.

NvidiaCuStateVec([shots, wires, multi_gpu])

The NVIDIA CuStateVec GPU simulator (with support for multi-gpu).

NvidiaCuTensorNet([shots, wires, mps])

The NVIDIA CuTensorNet GPU simulator (with support for matrix product state)