QJIT#

qjit(function)[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.

Returns:
callable

A function executing the compiled code.

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)]