QJIT#
- qjit(function=None, device=None)[source]#
Decorator to leverage the jasp + Catalyst infrastructure to compile the given function to QIR and run it on the Catalyst QIR runtime.
- Parameters:
- functioncallable
A function performing Qrisp code.
- deviceobject
The PennyLane device to execute the function. The default device is “lightning.qubit”, a fast state-vector qubit simulator.
- Returns:
- callable
A function executing the compiled code.
Notes
Lightning-GPU is compatible with systems featuring NVIDIA Volta (SM 7.0) GPUs or newer. It is specifically optimized for Linux environments on X86-64 or ARM64 architectures running CUDA-12.
To install Lightning-GPU with NVIDIA CUDA support, the following packages need to be installed
pip install custatevec_cu12 pip install pennylane-lightning-gpu
Pre-built wheels for Lightning-AMDGPU are available for AMD MI300 series GPUs and systems running ROCm 7.0 or newer.
pip install pennylane-lightning-amdgpu
If the setup uses an older version of ROCm or a different AMD GPU series, Lightning-AMDGPU must be built manually from source.
Installation instructions for different platforms are available at pennylane.ai/install.
Examples
We write a simple function using the QuantumFloat quantum type and execute via
qjit:from qrisp import * from qrisp.jasp import qjit @qjit def test_fun(i): qv = QuantumFloat(i, -2) with invert(): cx(qv[0], qv[qv.size-1]) h(qv[0]) meas_res = measure(qv) return meas_res + 3
We execute the function a couple of times to demonstrate the randomness
>>> test_fun(4) [array(5.25, dtype=float64)] >>> test_fun(5) [array(3., dtype=float64)] >>> test_fun(5) [array(7.25, dtype=float64)]
For executing on “lightning.gpu” we specify the device:
import pennylane as qml from qrisp import * from qrisp.jasp import qjit dev = qml.device("lightning.gpu", wires=0) @qjit(device=dev) def test_fun(i): qv = QuantumFloat(i, -2) with invert(): cx(qv[0], qv[qv.size-1]) h(qv[0]) meas_res = measure(qv) return meas_res + 3