iterate_expectation
fireopal.iterate_expectation(circuits, shot_count, credentials, backend_name, observables, parameters=None, run_options=None)Estimate expectation values of observables for quantum circuits with queue reuse.
Use this function to compute the expectation value of one or more observables for a batch of quantum circuits executed on a specified backend. Fire Opal automatically applies error suppression and mitigation to improve the accuracy of the estimated expectation values.
If permitted by the hardware provider, multiple calls to this function will re-use the same circuit submission queue position, reducing wait times for iterative workflows.
This is the recommended approach when you need to obtain expectation values iteratively (for example, for variational algorithms such as a Variational Quantum Eigensolver) rather than raw measurement bitstrings.
Parameters
- circuits (str or list [ str ]) – Quantum circuit(s) as QASM 2.0 or 3.0 strings. Convert Qiskit
QuantumCircuitobjects usingqiskit.qasm2.dumpsorqiskit.qasm3.dumps. - shot_count (int) – Number of bitstrings sampled from the final quantum state of each circuit.
- credentials (Credentials) – Credentials for the target hardware provider, created using the
appropriate helper from the
fireopal.credentialsmodule. For example, usemake_credentials_for_ibm_cloud()for IBM backends. - backend_name (str) – Name of the backend that will execute circuits.
- observables (PauliOperator or list [PauliOperator ] or str or list [ str ] or dict [ str , float ] or list [ tuple [ str , float ] ]) – Observable(s) for which to compute expectation values. Accepts Pauli
strings (for example,
"ZZI"), weighted dictionaries (for example,{"ZZI": 0.5, "IZZ": 0.5}), orPauliOperatorinstances. - parameters (dict [ str , float ] or list [ dict [ str , float ] ] or None , optional) – Parameter bindings for parametric circuit(s). Each dictionary maps parameter names to float values. Provide a list when submitting multiple circuits with distinct bindings. Defaults to None.
- run_options (RunOptions or None , optional) – Provider-specific execution options, for example,
IbmRunOptions). See thefireopal.run_optionsmodule for available classes. Defaults to None.
Returns
FireOpalJob – A job object whose result() method returns a dictionary
containing:
expectation_values (list[float])
: The estimated expectation values of the observables for each circuit.
standard_deviations (list[float])
: The standard deviations of the estimated expectation values,
accounting for shot noise.