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.

inject_results dict

Results loaded from previously serialized LabOne Q runs, returned in place of the measured results. A dictionary with the keys:

  • use: When to inject the results: "no" (never), "emulation" (only when the session runs in emulation mode) or "always".
  • paths: The files to load the results from. Results from several files are combined.
  • check_shapes: Whether to verify that the injected results match the shapes of the experiment results.

The sweep points are not injected, so pass the sweep points that the loaded results were measured with. Default: {"paths": [], "use": "emulation", "check_shapes": True}.

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.

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.