QuantumProgram¶
- class samplomatic.quantum_program.QuantumProgram(shots: int, items: Iterable[QuantumProgramItem] | None = None, noise_maps: dict[str, PauliLindbladMap] | None = None, meas_level: Literal['classified', 'kerneled', 'avg_kerneled', 'both'] = 'classified', passthrough_data: list[list[DataTree] | dict[str, DataTree] | ndarray[float] | str | float | int | bool | None] | dict[str, list[DataTree] | dict[str, DataTree] | ndarray[float] | str | float | int | bool | None] | ndarray[float] | str | float | int | bool | None = None)[source]¶
Bases:
objectA 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
shotsfor each set of circuit arguments provided.- Parameters:
shots – The number of shots for each circuit execution.
items – Items that comprise the program.
noise_maps – Noise maps to use with samplex items.
meas_level –
The level at which to return all classical register measurement results. This value sets the return type of all classical registers in all quantum program items and determines whether the raw complex data from low-level measurement devices is discriminated into bits or not. The allowed values are listed below; a backend should provide support for “classified”, but may choose not to support others.
- ”classified”: Classical register data is returned as boolean arrays with the
intrinsic shape
(num_shots, creg_size).
- ”kerneled”: Classical register data is returned as a complex array with the
intrinsic shape
(num_shots, creg_size), where each entry represents an IQ data point (resulting from kerneling the measurement trace) in arbitrary units.
- ”avg_kerneled”: Classical register data is returned as a complex array with the
intrinsic shape
(creg_size,), where data is equivalent to “kerneled” except additionally averaged over shots.
passthrough_data – Arbitrary nested data passed through execution without modification.
Methods Summary
append_circuit_item(circuit[, ...])Append a new
CircuitItemto this program.append_samplex_item(circuit, samplex[, ...])Append a new
SamplexItemto this program.Methods Documentation
- append_circuit_item(circuit: QuantumCircuit, circuit_arguments: ndarray | None = None, *, chunk_size: int | None = None) None[source]¶
Append a new
CircuitItemto this program.- Parameters:
circuit – The circuit of this item.
circuit_arguments – 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 – The maximum number of bound circuits in each shot loop execution, or
Noneto 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.
- append_samplex_item(circuit: QuantumCircuit, samplex: Samplex, samplex_arguments: dict[str, Any] | None = None, *, shape: tuple[int, ...] | None = None, chunk_size: int | None = None) None[source]¶
Append a new
SamplexItemto this program.- Parameters:
circuit – The circuit of this item.
samplex – A samplex to draw random parameters for the circuit.
samplex_arguments – A map from argument names to argument values for the samplex. Each argument array has intrinsic axes determined by its type (e.g.,
parameter_valueshas intrinsic shape(n,)fornparameters). The extrinsic shapes of all arguments are broadcasted together.shape – A shape that the item’s extrinsic shape must be broadcastable to. Axes where
shapeexceeds the shape implicit insamplex_argumentsenumerate independent randomizations.chunk_size – The maximum number of bound circuits in each shot loop execution, or
Noneto 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.