Haiqu.flow(program, circuits, shots=1000, parameters=None, observables=None, job_name=None, job_description=None, device_credentials=None, dry_run=False)
Run a flow (hybrid program). This flexible method supports multiple execution scenarios, with different combinations of circuits, parameters, and observables. When multiple values are provided for any of them, the results are returned as nested lists with up to 3 layers, ordered by circuits, then observables, and finally parameters.- Parameters:
- program (HybridProgram) — The hybrid program to execute.
- circuits (QuantumCircuit | list *[*QuantumCircuit ] | CircuitModel | list *[*CircuitModel ]) — The quantum circuit(s) to pass to the hybrid program. Can be a single circuit or a list of circuits.
- shots (int) — The number of shots for each circuit execution. Defaults to 1000.
-
parameters (list | None) — The parameters for the circuits. Can be a single set of parameters or nested lists of parameter sets. For
multiple circuits, must be a list where each element corresponds to parameters for that circuit. Defaults
to
None, in which case the circuits must not have any parameters. -
observables (SparsePauliOp | list *[*SparsePauliOp ] | list *[*list *[*SparsePauliOp ] ] | None) —
The observable(s) to measure. The order of Pauli terms in a single string follows the Qiskit
reversed-order convention (e.g.,
"IZ"measures qubit 0 in the Z basis). Defaults toNone, in which case the circuits must include their own measurements. Accepted shapes:- Single circuit: a single
SparsePauliOp, the nested form[[op1, op2, ...]], or a bare list[op1, op2, ...]. - Multiple circuits: a list of length
num_circuits, where each element is independently either a singleSparsePauliOp(one observable on that circuit) or a list ofSparsePauliOp(multiple observables on that circuit). Mixing is allowed —[[op1, op2], op3]for two circuits is valid.
- Single circuit: a single
-
job_name (str | None) — The name for the job. If
None(default), a name will be automatically generated. - job_description (str | None) — The description for the job.
- device_credentials (dict | None) — Credentials for device access.
-
dry_run (bool) — Whether to stop just prior to backend execution for QPU cost estimation. Defaults to
False. WhenTrue, the job result will be empty since execution on the device is skipped. The estimated QPU cost is then available viajob.estimated_qpu_cost.
- Returns:
The Hybrid job that will execute the hybrid program.
: Call
job.result()to retrieve the execution results as a nested list ordered by circuits → observables → parameters:- Without observables: list of measurement distributions (
dict[bitstring, quasi-probability]), one per circuit, in Qiskit bit-order. - With observables, no parameter sweep: 2D list of expectation values, indexed
[circuit][observable]. - With observables and a parameter sweep: 3D list of expectation values, indexed
[circuit][observable][parameter].
Whendry_run=True,result()is empty; usejob.estimated_qpu_costinstead.job.infoexposes auxiliary metadata (uncertaintywhen observables are supplied,qpu_cost). Runhelp(job.result)for the full description of result andinfocontents. - Without observables: list of measurement distributions (
- Return type: HybridJobModel