Catalyst Quantum Runtime

The Catalyst Runtime is a C++ QIR runtime that enables the execution of Catalyst-compiled quantum programs, and is currently backed by PennyLane-Lightning state-vector simulators, and Amazon Braket devices. Additional hardware support, including QPUs, to come.

The runtime employs the QuantumDevice public interface to support an extensible list of backend devices. This interface comprises two collections of abstract methods:

  • The Qubit management, device shot noise, and quantum tape recording methods are utilized for the implementation of Quantum Runtime (QR) instructions.

  • The quantum operations, observables, measurements, and gradient methods are used to implement Quantum Instruction Set (QIS) instructions.

A complete list of instructions supported by the runtime can be found in RuntimeCAPI.h.

Contents

The directory is structured as follows:

  • include:

    This contains the public header files of the runtime including the QuantumDevice API for backend quantum devices and the runtime CAPI.

  • extensions:

    A collection of extensions for backend simulators to fit into the QIR programming model. The StateVectorLQubitDynamic class extends the state-vector class of Pennylane-Lightning providing dynamic allocation and deallocation of qubits.

  • lib:

    The core modules of the runtime are structured into lib/capi and lib/backend. lib/capi implements the bridge between QIR instructions in LLVM-IR and C++ device backends. lib/backend contains implementations of the QuantumDevice API for backend simulators.

  • tests:

    A collection of C++ tests for modules and methods in the runtime.

Backend Devices

New device backends for the runtime can be realized by implementing the quantum device interface. The following table shows the available devices along with supported features:

Features

PennyLane-Lightning

PennyLane-Lightning-Kokkos

Amazon-Braket-OpenQasm

Qubit Management

Dynamic allocation/deallocation

Static allocation/deallocation

Static allocation/deallocation

Gate Operations

Lightning operations

Lightning operations

Braket operations

Quantum Observables

Identity, PauliX, PauliY, PauliZ, Hadamard, Hermitian, Hamiltonian, and Tensor Product of Observables

Identity, PauliX, PauliY, PauliZ, Hadamard, Hermitian, Hamiltonian, and Tensor Product of Observables

Identity, PauliX, PauliY, PauliZ, Hadamard, Hermitian, and Tensor Product of Observables

Expectation Value

All observables; Finite-shots supported except for Hermitian

All observables; Finite-shots supported except for Hermitian

All observables; Finite-shots supported

Variance

All observables; Finite-shots supported except for Hermitian

All observables; Finite-shots supported except for Hermitian

All observables; Finite-shots supported

Probability

Only for the computational basis on the supplied qubits; Finite-shots supported except for Hermitian

Only for the computational basis on the supplied qubits; Finite-shots supported except for Hermitian

The computational basis on all active qubits; Finite-shots supported

Sampling

Only for the computational basis on the supplied qubits

Only for the computational basis on the supplied qubits

The computational basis on all active qubits; Finite-shots supported

Mid-Circuit Measurement

Only for the computational basis on the supplied qubit

Only for the computational basis on the supplied qubit

Not supported

Gradient

The Adjoint-Jacobian method for expectation values on all observables

The Adjoint-Jacobian method for expectation values on all observables

Not supported

Requirements

To build the runtime from source, it is required to have an up to date version of a C/C++ compiler such as gcc or clang with support for the C++20 standard library and the static library of stdlib from qir-runner.

Installation

By default, the runtime leverages lightning.qubit as the backend simulator. You can build the runtime with multiple devices from the list of Backend Devices. You can use ENABLE_LIGHTNING_KOKKOS=ON to build the runtime with lightning.kokkos:

make runtime ENABLE_LIGHTNING_KOKKOS=ON

Lightning-Kokkos provides support for other Kokkos backends including OpenMP, HIP and CUDA. Please refer to the installation guideline for the requirements. You can further use the CMAKE_ARGS flag to issue any additional compiler arguments or override the preset ones in the make commands. To build the runtime with Lightning-Kokkos and the Kokkos::OpenMP backend execution space:

make runtime ENABLE_LIGHTNING_KOKKOS=ON CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON"

You can also use ENABLE_OPENQASM=ON to build the runtime with Amazon-Braket-OpenQasm:

make runtime ENABLE_OPENQASM=ON

This device currently offers generators for the OpenQasm3 specification and Amazon Braket assembly extension. Moreover, the generated assembly can be executed on Amazon Braket devices leveraging amazon-braket-sdk-python.

The runtime leverages the qir-stdlib pre-built artifacts from qir-runner by default. To build this package from source, a Rust toolchain installed via rustup is required. You can build the runtime with BUILD_QIR_STDLIB_FROM_SRC=ON after installing the llvm-tools-preview component:

rustup component add llvm-tools-preview
make runtime BUILD_QIR_STDLIB_FROM_SRC=ON

To check the runtime test suite:

make test

You can also build and test the runtime (and qir-stdlib) from the top level directory via make runtime and make test-runtime.