Select local Selene or a Nexus device for HUGR program execution.
Overview¶
| Class | Description |
|---|---|
HugrExecutionTarget | Identify a supported HUGR execution destination. |
HugrExecutor | Execute HUGR packages on local Selene or Nexus devices. |
NexusExecutionOptions | Configure execution on a Helios or H2 target through Nexus. |
SeleneExecutionOptions | Configure local Selene execution. |
Classes¶
HugrExecutionTarget [source]¶
class HugrExecutionTarget(StrEnum)Identify a supported HUGR execution destination.
Attributes¶
HELIOSNEXUSSELENE
HugrExecutor [source]¶
class HugrExecutorExecute HUGR packages on local Selene or Nexus devices.
The nexus destination selects HUGR or QIR submission from the device
configured in :class:NexusExecutionOptions. The existing helios
destination remains an alias for Nexus execution. Nexus authentication
starts on the first submission or restoration, and project names are
resolved internally when submitting a job.
Parameters:
| Name | Type | Description |
|---|---|---|
target | str | HugrExecutionTarget | Destination, default selene. |
options | SeleneExecutionOptions | NexusExecutionOptions | None | Destination-specific settings. Defaults to the destination defaults. |
Raises:
ValueError— If the destination is unknown.TypeError— If options belong to another destination.
Example:
>>> executor = HugrExecutor(options=SeleneExecutionOptions(seed=7))
>>> remote = HugrExecutor("helios", options=NexusExecutionOptions())
>>> h2 = HugrExecutor(
... "nexus", options=NexusExecutionOptions(system_name="H2-1E")
... )Constructor¶
def __init__(
self,
target: str | HugrExecutionTarget = HugrExecutionTarget.SELENE,
*,
options: SeleneExecutionOptions | NexusExecutionOptions | None = None,
) -> NoneInitialize the destination and local compilation cache.
Parameters:
| Name | Type | Description |
|---|---|---|
target | str | HugrExecutionTarget | Selene or Nexus destination. helios is retained as a Nexus alias. |
options | SeleneExecutionOptions | NexusExecutionOptions | None | Destination-specific configuration. |
Raises:
ValueError— If the destination is unknown.TypeError— If options are incompatible with the destination.
Attributes¶
capabilities: ExecutionCapabilities Describe this destination’s actual execution features.optionstarget
Methods¶
retrieve¶
def retrieve(self, reference: ExecutionReference) -> ExecutionHandle[list[dict[str, Any]]]Restore a remote tagged execution without resubmitting it.
Parameters:
| Name | Type | Description |
|---|---|---|
reference | ExecutionReference | Saved Nexus job reference. |
Returns:
ExecutionHandle[list[dict[str, Any]]] — ExecutionHandle[list[dict[str, Any]]]: Restored remote handle.
Raises:
ValueError— If the destination is local or reference is invalid.Exception— If the provider cannot retrieve the referenced job.
submit¶
def submit(
self,
package: Package,
shots: int = 1024,
) -> ExecutionHandle[list[dict[str, Any]]]Submit a zero-argument HUGR entrypoint with recorded outputs.
Use HugrExecutable for ABI-aware runtime arguments and typed jobs.
Parameters:
| Name | Type | Description |
|---|---|---|
package | Package | HUGR package with a zero-argument main function. |
shots | int | Number of repetitions, default 1024. |
Returns:
ExecutionHandle[list[dict[str, Any]]] — ExecutionHandle[list[dict[str, Any]]]: Tagged values for each shot.
Raises:
ValueError— If shots is invalid or output tags repeat.ImportError— If destination dependencies are missing.RuntimeError— If the simulator returns an incorrect shot count.Exception— If provider compilation or submission fails.
NexusExecutionOptions [source]¶
class NexusExecutionOptionsConfigure execution on a Helios or H2 target through Nexus.
Parameters:
| Name | Type | Description |
|---|---|---|
project | Any | None | Nexus project name or native qnexus project reference. A name is looked up or created when submitting a job. None uses the active Nexus project, or looks up or creates qamomile if no project is active. Authentication is automatic on the first submission or restoration; an initial login may require browser approval. |
backend_config | Any | None | Native qnexus.HeliosConfig or H2 qnexus.QuantinuumConfig with optional device settings. Its system_name or device_name overrides system_name below. |
system_name | str | Device name, defaulting to Helios-1. Helios receives HUGR; H2 receives automatically converted QIR. H2 requires Python 3.11 or 3.12 with the hugr extra and Bit public outputs. Every H2 shot read uses a zero-based logical index, normalized from the internal device origin before QIR conversion. Helios uses an internal zero-based origin policy and preserves shot reads without rewriting the upload; its device origin remains unverified. |
name | str | Program and job name prefix. Each submission receives a unique suffix, including separate expectation measurement jobs. |
max_cost | float | None | Optional maximum HQC cost for each submitted program. Required when submitting to Helios; saved jobs can be restored without it. A deprecated native config limit is used when omitted, and conflicting limits are rejected. This is not an aggregate expectation-estimation budget. |
n_qubits | int | None | Optional maximum qubit count passed to Nexus. |
credential_name | str | None | Name of a credential already in Nexus. |
user_group | str | None | Nexus user group for scheduling. |
target_region | str | NexusRegion | None | Execution region, us or sg. |
poll_interval_seconds | float | Positive local status polling interval. |
timeout_seconds | float | None | Default local status-wait deadline. None waits indefinitely. Timing out never cancels a job. |
Raises:
ValueError— If a numeric option, project name, region, or config is invalid.
Constructor¶
def __init__(
self,
project: Any | None = None,
backend_config: Any | None = None,
system_name: str = 'Helios-1',
name: str = 'qamomile-hugr',
max_cost: float | None = None,
n_qubits: int | None = None,
credential_name: str | None = None,
user_group: str | None = None,
target_region: str | NexusRegion | None = None,
poll_interval_seconds: float = 1.0,
timeout_seconds: float | None = None,
) -> NoneAttributes¶
backend_config: Any | Nonecredential_name: str | Nonemax_cost: float | Nonen_qubits: int | Nonename: strpoll_interval_seconds: floatproject: Any | Nonesystem_name: strtarget_region: str | NexusRegion | Nonetimeout_seconds: float | Noneuser_group: str | None
SeleneExecutionOptions [source]¶
class SeleneExecutionOptionsConfigure local Selene execution.
Parameters:
| Name | Type | Description |
|---|---|---|
seed | int | None | Reproducible simulator seed, or provider default. |
n_qubits | int | None | Simulator capacity override. By default use an allocation bound expanded through the submitted call graph. |
timeout_seconds | float | None | Maximum simulator execution duration. |
build_dir | Path | None | Root for persistent isolated compilation directories. If omitted, the executor owns a temporary directory that is removed when the executor is released. |
Raises:
ValueError— If a numeric option is invalid.TypeError— If the seed or capacity is not an integer.
Constructor¶
def __init__(
self,
seed: int | None = None,
n_qubits: int | None = None,
timeout_seconds: float | None = None,
build_dir: Path | None = None,
) -> NoneAttributes¶
build_dir: Path | Nonen_qubits: int | Noneseed: int | Nonetimeout_seconds: float | None