Skip to main contentIBM Quantum Documentation Mirror

QuantumProgram

class QuantumProgram(shots, items=None, noise_maps=None, meas_level='classified', passthrough_data=None)

GitHub

Bases: object

A quantum runtime executable.

A quantum program consists of a list of ordered elements, each of which contains a single circuit and an array of associated parameter values. Executing a quantum program will sample the outcome of each circuit for the specified number of shots for each set of circuit arguments provided.

Parameters

  • shots (int) – The number of shots for each circuit execution.
  • items (Iterable[QuantumProgramItem] | None) – Items that comprise the program.
  • noise_maps (dict[str, PauliLindbladMap] | None) – Noise maps to use with samplex items.
  • passthrough_data (DataTree | None) – Arbitrary nested data passed through execution without modification.
  • meas_level (Literal['classified', 'kerneled', 'avg_kerneled'])

Methods

append_circuit_item

append_circuit_item(circuit, *, circuit_arguments=None, chunk_size=None)

GitHub

Append a new CircuitItem to this program.

Parameters

  • circuit (QuantumCircuit) – The circuit of this item.
  • circuit_arguments (ndarray | None) – A real-valued array of parameter values for the circuit. The last axis is intrinsic with size equal to the number of circuit parameters. Leading axes are extrinsic and define the sweep grid.
  • chunk_size (int | None) – The maximum number of bound circuits in each shot loop execution, or None to use a server-side heuristic to optimize speed. When not executing in a session, the server-side heuristic is always used and this value is ignored.

Return type

None

append_samplex_item

append_samplex_item(circuit, *, samplex, samplex_arguments=None, shape=None, chunk_size=None)

GitHub

Append a new SamplexItem to this program.

Parameters

  • circuit (QuantumCircuit) – The circuit of this item.
  • samplex (Samplex) – A samplex to draw random parameters for the circuit.
  • samplex_arguments (dict[str, Any] | None) – A map from argument names to argument values for the samplex. Each argument array has intrinsic axes determined by its type (e.g., parameter_values has intrinsic shape (n,) for n parameters). The extrinsic shapes of all arguments are broadcasted together.
  • shape (tuple[int, ...] | None) – A shape that the item’s extrinsic shape must be broadcastable to. Axes where shape exceeds the shape implicit in samplex_arguments enumerate independent randomizations.
  • chunk_size (int | None) – The maximum number of bound circuits in each shot loop execution, or None to use a server-side heuristic to optimize speed. When not executing in a session, the server-side heuristic is always used and this value is ignored.

Return type

None