laboneq.workflow.tasks.create_qasm_experiment

This module provides a task to create an experiment from an OpenQASM program.

create_qasm_batch_experiment(qpu, programs, qubit_map, inputs=None, externs=None, options=None)

A task to create a QASM batch experiment.

Parameters:

Name Type Description Default
qpu QPU

The quantum processing unit to create the experiment for.

required
programs list[str]

List of OpenQASM program.

required
qubit_map dict[str, QuantumElement | list[QuantumElement]]

A map from OpenQASM qubit names to LabOne Q DSL Qubit objects. The values can either be a single qubit or a list of qubits in case of an qubit register.

required
inputs dict[str, Any] | None

Inputs to the program.

None
externs dict[str, Callable | Port] | None

A mapping for program extern definitions.

Externs may be either functions (Python callables) or ports on qubit signals.

None
options SingleProgramOptions | dict | None

Optional settings for the LabOne Q Experiment.

Default: MultiProgramOptions

Accepts also a dictionary with the following items:

count: The number of acquire iterations.

acquisition_mode: The mode of how to average the acquired data.

acquisition_type: The type of acquisition to perform. The acquisition type may also be specified within the OpenQASM program using pragma zi.acqusition_type raw, for example. If an acquisition type is passed here, it overrides any value set by a pragma. If the acquisition type is not specified, it defaults to enums.AcquisitionType.INTEGRATION.

reset_oscillator_phase: When true, reset all oscillators at the start of every acquisition loop iteration.

repetition_time: The minimum duration of any single program. If None, the default, each program runs for its own duration. If not None, any program shorter than repetition_time is padded to reach the given length. Programs longer than repetition_time will keep their longer length. The length of each program excludes the length of any resets or measurements added using add_reset or add_measurement.

batch_execution_mode: The execution mode for the sequence of programs. Can be any of the following.

  • nt: The individual programs are dispatched by software.
  • pipeline: The individual programs are dispatched by the sequence pipeliner.
  • rt: All the programs are combined into a single real-time program.

rt offers the fastest execution, but is limited by device memory. In comparison, pipeline introduces non-deterministic delays between programs of up to a few 100 microseconds. nt is the slowest.

do_reset: If True, an active reset operation is added to the beginning of each program.

Note: Requires reset(qubit) operation to be defined for each qubit.

add_measurement: If True, add measurement at the end of each program for all qubits used. The measurement results for each qubit are stored in a handle named 'meas{qasm_qubit_name}' where qasm_qubit_name is the key specified for the qubit in the qubit_map parameter.

Note: Requires measure(qubit, handle: str) operation to be defined for each qubit.

pipeline_chunk_count: The number of pipeline chunks to divide the experiment into.

None

Returns:

Type Description
Experiment

A LabOne Q Experiment.

Raises:

Type Description
ValueError

Supplied qubit(s) does not exists in the QPU.

OpenQasmException

The program cannot be transpiled.

create_qasm_experiment(qpu, program, qubit_map, inputs=None, externs=None, options=None)

A task to create a QASM experiment.

This task is used to create a QASM experiment for execution on a quantum processor.

Parameters:

Name Type Description Default
qpu QPU

The quantum processing unit to create the experiment for.

required
program str

OpenQASM program.

required
qubit_map dict[str, QuantumElement | list[QuantumElement]]

A map from OpenQASM qubit names to LabOne Q DSL Qubit objects. The values can either be a single qubit or a list of qubits in case of an qubit register.

required
inputs dict[str, Any] | None

Inputs to the program.

None
externs dict[str, Callable | Port] | None

A mapping for program extern definitions.

Externs may be either functions (Python callables) or ports on qubit signals.

None
options SingleProgramOptions | dict | None

Optional settings for the LabOne Q Experiment.

Default: SingleProgramOptions

Accepts also a dictionary with following items:

count: The number of acquire iterations.

acquisition_mode: The mode of how to average the acquired data.

acquisition_type: The type of acquisition to perform. The acquisition type may also be specified within the OpenQASM program using pragma zi.acqusition_type raw, for example. If an acquisition type is passed here, it overrides any value set by a pragma. If the acquisition type is not specified, it defaults to enums.AcquisitionType.INTEGRATION.

reset_oscillator_phase: When true, reset all oscillators at the start of every acquisition loop iteration.

None

Returns:

Type Description
Experiment

A LabOne Q Experiment.

Raises:

Type Description
ValueError

Supplied qubit(s) does not exists in the QPU.

OpenQasmException

The program cannot be transpiled.