Skip to content

laboneq.workflow.tasks.run_experiment

This module provides a task to run a compiled experiment in a session.

RunExperimentResults = Results module-attribute

RunExperimentOptions

Options for the run_experiment task.

Attributes:

Name Type Description
include_results_metadata bool

Passed to Session.run to specify whether the .device_setup, .experiment and .compiled_experiment attributes of the result should be populated. Default: False.

return_legacy_results bool

Alias for include_results_metadata. Deprecated. Default: False.

Added in version 2.52.0

The option include_results_metadata was added.

Deprecated in version 2.52.0

A new unified Results class was introduced to LabOne Q. Previously return_legacy_results specified whether to return the LabOne Q Results class or its own RunExperimentResults class. Now the unified Results class is always returned but the value of return_legacy_results determines via the Session which attributes should be set on the results and is equivalent to the new include_results_metadata.

include_results_metadata = workflow.option_field(False, description='Passed to `Session.run` to specify whether the `.device_setup`, `.experiment` and `.compiled_experiment` attributes of the result should be populated.') class-attribute instance-attribute

inject_results = workflow.option_field(factory=(lambda: {'paths': [], 'use': 'emulation', 'check_shapes': True}), validators=[_validate_inject_results], converter=(lambda v: {None: v, 'paths': [(str(p)) for p in (v.get('paths', []))]}), description="Inject results loaded from a previously serialized LabOne Q run.\n\n!!! Note: the sweep points are not injected. Please make sure that the\nsweep point values you pass to the workflow are the same as those that\nwere used in the experiment you are loading the data for.\n\nKeys:\n - use (Literal['no', 'emulation', 'always']): Controls when to inject results.\n * 'no' : never inject\n * 'emulation' : inject only when running in emulation mode (default)\n * 'always' : inject regardless of mode\n Default: 'emulation'\n - paths (list[Path | str]): Paths to load results from.\n If multiple paths are provided, then the results are combined.\n Default: []\n - check_shapes (bool): Whether to verify that injected results match the\n expected shapes of the experiment results.\n Default: True\n") class-attribute instance-attribute

return_legacy_results = workflow.option_field(False, description='Alias for `include_results_metadata`. Deprecated.') class-attribute instance-attribute

run_experiment(session, compiled_experiment, *, options=None)

Run the compiled experiment on the quantum processor via the specified session.

Parameters:

Name Type Description Default
session Session

The connected session to use for running the experiment.

required
compiled_experiment CompiledExperiment

The compiled experiment to run.

required
options RunExperimentOptions | None

The options for this task as an instance of [RunExperimentOptions].

None

Returns:

Type Description
Results

The measurement results.