Catalyst Runtime¶
The Catalyst Runtime is a C++ QIR runtime that enables the execution of Catalyst-compiled quantum programs, and is currently backed by state-vector simulators PennyLane-Lightning and Pennylane-Lightning-Kokkos.
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 StateVectorDynamicCPU 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
andlib/backend
. lib/capi implements the bridge between QIR instructions in LLVM-IR and C++ device backends. lib/backend contains implementations of theQuantumDevice
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 |
Qubit Management |
Dynamic allocation/deallocation |
Static allocation/deallocation |
Gate Operations |
||
Quantum Observables |
|
|
Expectation Value |
All observables; Finite-shots not supported |
All observables; Finite-shots not supported |
Variance |
Only for |
All observables; Finite-shots not supported |
Probability |
Only for the computational basis on the supplied qubits; Finite-shots not supported |
Only for the computational basis on the supplied qubits; Finite-shots not supported |
Sampling |
Only for the computational basis on the supplied qubits |
Only for the computational basis on the supplied qubits |
Mid-Circuit Measurement |
Only for the computational basis on the supplied qubit |
Only for the computational basis on the supplied qubit |
Gradient |
The Adjoint-Jacobian method for expectation values on all observables |
The Adjoint-Jacobian method for expectation values on all observables |
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.
The runtime leverages the stdlib
Rust package for the QIR standard runtime instructions. To build this package from source,
the Rust toolchain installed via rustup
is also required.
Installation¶
By default, the runtime leverages Pennylane-Lightning as the backend simulator.
You can use the CMake flag -DENABLE_LIGHTNING_KOKKOS
to build the runtime with Pennylane-Lightning-Kokkos
in the serial mode or run:
ENABLE_KOKKOS=ON make runtime
Lightning-Kokkos provides support for other Kokkos backends including OpenMP, HIP and CUDA. Please refer to the installation guideline for the requirements.
The runtime uses the QIR standard library for basic QIR instructions.
Before building stdlib
, the llvm-tools-preview
Rustup component needs to be installed:
rustup component add llvm-tools-preview
To build the static library of stdlib
:
make qir
And use CMake flags -DQIR_STDLIB_LIB
and -DQIR_STDLIB_INCLUDES
to respectively locate libqir_stdlib.a
and qir_stdlib.h
, or run:
QIR_STDLIB_DIR=$(pwd)/qir-stdlib/target/release QIR_STDLIB_INCLUDES_DIR=$(pwd)/qir-stdlib/target/release/build/include make runtime
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
.