Runtime

Selene uses a runtime to manage compilation of Guppy programs into an executable binary. Each runtime requires a different compiler. Compilation from guppy programs into executable binaries is performed internally within Selene, and is not required by the user. The user is only responsible for compiling Guppy into hugr.

The runtime is responsible for routing quantum operations from the executable binary for execution on the simulator. If an error model instance is specified, Quantum operations are routed through and modified by the error model.

The HUGR corresponding to a 4-qubit GHZ state is used with Selene.

from guppylang import guppy
from guppylang.std.builtins import array, result
from guppylang.std.quantum import qubit, measure, h, cx, measure

@guppy
def main() -> None:
    qubit_top = qubit()
    h(qubit_top)
    qubits = array(qubit() for _ in range(3))
    for q in qubits:
        cx(qubit_top, q)
        m = measure(q)
        result("result", m)
    m_top = measure(qubit_top)
    result("result", m_top)

hugr = main.compile()

Simple Runtime

Simple runtime does not include Helios-specific features or on-the-fly ion transport calculations Additionally, it stores requested gate operations into a queue. Upon request for a measurement result, all gate operations, before the corresponding measurement operation are performed.

from selene_sim import build, Quest, SimpleRuntime
from hugr.qsystem.result import QsysResult

runner = build(hugr)

simple_runtime = SimpleRuntime()

simulator = Quest()

qsys_result = QsysResult(runner.run_shots(
    simulator, 
    n_qubits=4,
    runtime=simple_runtime,
    n_shots=100,
))

qsys_result.collated_counts()
Counter({(('result', '0000'),): 51, (('result', '1111'),): 49})