Next Generation Stack

Guppy is a quantum-first programming language that leverages the next-generation runtime on Helios to execute programs with arbitrary control flow and classical compute. More information is available at Guppy documentation. Nexus is a cloud-native Platform-as-a-Service (PaaS) that provides access to Quantinuum Helios, in addition to cloud Selene instances. A workflow schematic is provided below.

NG Stack

Quantinuum Helios and the Selene emulators distributions can be accessed via the Guppy submission pathway.

Job Workflow

Initialize A Helios project. A UUID can be used to suffix resources names for uniqueness.

import qnexus as qnx
import uuid

unique_suffix = uuid.uuid1()

project = qnx.projects.get_or_create("Helios-Samples")
qnx.context.set_active_project(project)

Write Guppy source and build a compact representation (HUGR).

from guppylang import guppy
from guppylang.std.quantum import qubit, toffoli, s, measure
from guppylang.std.quantum.functional import h

@guppy
def repeat_until_success(q: qubit, attempts: int) -> bool:
    """
    Repeat-until-success circuit for Rz(acos(3/5))
    from Nielsen and Chuang, Fig. 4.17.
    """
    for i in range(attempts):
        a, b = h(qubit()), h(qubit())
        toffoli(a, b, q)
        s(q)
        toffoli(a, b, q)
        if not (measure(h(a)) | measure(h(b))):
            result("rus_attempts", i)
            return True
    return False

hugr_binary = repeat_until_success.compile()

Upload HUGR to the Nexus Database. The user can access reference to the HUGR to request actions (costing, execution) on the underlying HUGR program.

ref_hugr = qnx.hugr.upload(
    hugr_binary, 
    name=f"repeat-until-success-{unique_suffix}"
)

The Helios syntax checkers can be queried for an estimate on the maximum cost specification.

prediction = qnx.hugr.cost(
    programs=[ref_hugr], 
    n_shots=[10]
)

A QuantinuumConfig instance with the device_name and the max_cost needs to be specified.

import numpy as np

config = qnx.QuantinuumConfig(
    device_name="Helios-1E",
    max_cost=np.ceil(prediction)
)

A QuantinuumConfig instance is supplied to the start execution job function, alongside the HUGR reference, the number of shots and a job name.

import numpy as np
result_ref = qnx.start_execute_job(
    programs=[ref_hugr],
    n_shots=[10],
    backend_config=config,
    name=f"Helios-Emulator-{unique_suffix}"
)

The job result can be queried once ready. The query can be blocked if the result is not ready with the {py:func}‘qnexus.jobs.wait_for’ function.

qnx.jobs.wait_for(result_ref)
job_result = qnx.jobs.results(result_ref)[0].download_result()