Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit Runtime client and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

EstimatorV1

class EstimatorV1(backend=None, session=None, options=None)

GitHub

Class for interacting with Qiskit Runtime Estimator primitive service.

Deprecated since version 0.23

The EstimatorV1 primitives have been deprecated in 0.23, released on April 15, 2024. See the V2 migration guide. for more details. The EstimatorV1 support will be removed no earlier than July 15, 2024.

Qiskit Runtime Estimator primitive service estimates expectation values of quantum circuits and observables.

The run() can be used to submit circuits, observables, and parameters to the Estimator primitive.

You are encouraged to use Session to open a session, during which you can invoke one or more primitives. Jobs submitted within a session are prioritized by the scheduler.

Example:

from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp
 
from qiskit_ibm_runtime import QiskitRuntimeService, Estimator
 
service = QiskitRuntimeService(channel="ibm_cloud")
 
psi1 = RealAmplitudes(num_qubits=2, reps=2)
 
H1 = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
H2 = SparsePauliOp.from_list([("IZ", 1)])
H3 = SparsePauliOp.from_list([("ZI", 1), ("ZZ", 1)])
 
with Session(service=service, backend="ibmq_qasm_simulator") as session:
    estimator = Estimator(session=session)
 
    theta1 = [0, 1, 1, 2, 3, 5]
 
    # calculate [ <psi1(theta1)|H1|psi1(theta1)> ]
    psi1_H1 = estimator.run(circuits=[psi1], observables=[H1], parameter_values=[theta1])
    print(psi1_H1.result())
 
    # calculate [ <psi1(theta1)|H2|psi1(theta1)>, <psi1(theta1)|H3|psi1(theta1)> ]
    psi1_H23 = estimator.run(
        circuits=[psi1, psi1],
        observables=[H2, H3],
        parameter_values=[theta1]*2
    )
    print(psi1_H23.result())

Initializes the Estimator primitive.

Parameters

  • backend (Union[str, IBMBackend, None]) – Backend to run the primitive. This can be a backend name or an IBMBackend instance. If a name is specified, the default account (e.g. QiskitRuntimeService()) is used.

  • session (Optional[Session]) –

    Session in which to call the primitive.

    If both session and backend are specified, session takes precedence. If neither is specified, and the primitive is created inside a qiskit_ibm_runtime.Session context manager, then the session is used. Otherwise if IBM Cloud channel is used, a default backend is selected.

  • options (Union[Dict, Options, None]) – Primitive options, see Options for detailed description. The backend keyword is still supported but is deprecated.


Attributes

options

Return options values for the sampler. :rtype: Options :returns: options

session

Return session used by this primitive.

Return type

Optional[Session]

Returns

Session used by this primitive, or None if session is not used.

version

Default value: 1


Methods

run

run(circuits, observables, parameter_values=None, **kwargs)

GitHub

Submit a request to the estimator primitive.

Parameters

  • circuits (QuantumCircuit | Sequence[QuantumCircuit]) – a (parameterized) QuantumCircuit or a list of (parameterized) QuantumCircuit.
  • observables (Sequence[BaseOperator | str] | BaseOperator | str) – Observable objects.
  • parameter_values (Sequence[float] | Sequence[Sequence[float]] | None) – Concrete parameters to be bound.
  • **kwargs – Individual options to overwrite the default primitive options.

Return type

RuntimeJob

Returns

Submitted job. The result of the job is an instance of qiskit.primitives.EstimatorResult.

Raises

ValueError – Invalid arguments are given.

set_options

set_options(**fields)

GitHub

Set options values for the sampler.

Parameters

**fields – The fields to update the options

Return type

None

Was this page helpful?
Report a bug or request content on GitHub.