Skip to main content
IBM Quantum Platform
翻訳情報

このページの追加言語翻訳は近日公開予定です。

EstimatorV2

class EstimatorV2(mode=None, options=None)

GitHub

Bases: BasePrimitiveV2[EstimatorOptions], Estimator, BaseEstimatorV2

EstimatorV2 primitive for IBM Quantum Compute (formerly Qiskit Runtime).

IBM Quantum Compute 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.

Following construction, an estimator is used by calling its run() method with a list of PUBs (Primitive Unified Blocs). Each PUB contains four values that, together, define a computation unit of work for the estimator to complete:

  • a single QuantumCircuit, possibly parametrized, whose final state we define as ψ(θ)\psi(\theta),
  • one or more observables (specified as any ObservablesArrayLike, including Pauli, SparsePauliOp, str) that specify which expectation values to estimate, denoted HjH_j, and
  • a collection parameter value sets to bind the circuit against, θk\theta_k.
  • an optional target precision for expectation value estimates.

Here is an example of how the estimator is used.

from qiskit.circuit.library import real_amplitudes
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2 as Estimator

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)

psi = real_amplitudes(num_qubits=2, reps=2)
hamiltonian = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
theta = [0, 1, 1, 2, 3, 5]

pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_psi = pm.run(psi)
isa_observables = hamiltonian.apply_layout(isa_psi.layout)

estimator = Estimator(mode=backend)

# calculate [ <psi(theta)|hamiltonian|psi(theta)> ]
job = estimator.run([(isa_psi, isa_observables, [theta])])
pub_result = job.result()[0]
print(f"Expectation values: {pub_result.data.evs}")

Parameters


Attributes

mode

Return the execution mode used by this primitive.

Returns

Mode used by this primitive, or None if an execution mode is not used.

options

Return options.

version

Default value: 2


Methods

backend

backend()

GitHub

Return the backend the primitive query will be run on.

Return type

BackendV2

run

run(pubs, *, precision=None, dry_run=False)

GitHub

Submit a request to the estimator primitive.

Parameters

  • pubs (Iterable[EstimatorPubLike]) – An iterable of pub-like (primitive unified bloc) objects, such as tuples (circuit, observables) or (circuit, observables, parameter_values).
  • precision (float | None) – The target precision for expectation value estimates of each run Estimator Pub that does not specify its own precision. If None, the estimator’s default precision value will be used.
  • dry_run (bool) – If True, performs a dry run without executing the job on a QPU. This mode can be used to validate the job, estimate usage consumption, and retrieve circuit timing metadata. Returned results preserve the expected schema but contain randomized mock data rather than actual or simulated measurement results. Unlike the fake backends, the processing of this dry run happens on the server-side, so the job may not finish immediately and access to this feature may be restricted.

Returns

Submitted job.

Raises

ValueError – if precision value is not strictly greater than 0.

Return type

RuntimeJobV2

このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。