Skip to content

Variational runtime

For parametric circuits (VQE, QAOA), ParametricRuntime compiles the template once and binds parameters locally on every later call.

The cache key is a SHA-256 of the circuit's structural signature. Different parameter values share an entry; a different gate sequence forces a recompile.

from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from limbo_quantum import ParametricRuntime, InProcessCompilerClient

theta = Parameter("theta")
qc = QuantumCircuit(2)
qc.ry(theta, 0)
qc.cx(0, 1)
qc.measure_all()

runtime = ParametricRuntime(qc, client=InProcessCompilerClient())

for theta_val in [0.0, 0.1, 0.2, 0.3]:
    result = runtime.run({theta: theta_val}, shots=512)
    # First call: full compile. Every later call: bind only.
    print(theta_val, result.counts)

HTTPCompilerClient targets the hosted backend instead of compiling in process; it will be usable once the hosted service launches.