Skip to content

Implement estimator interface#148

Open
jsaroni wants to merge 3 commits into
Qiskit:mainfrom
jsaroni:implementing_estimator_interface
Open

Implement estimator interface#148
jsaroni wants to merge 3 commits into
Qiskit:mainfrom
jsaroni:implementing_estimator_interface

Conversation

@jsaroni
Copy link
Copy Markdown

@jsaroni jsaroni commented Jun 4, 2026

Summary

Implements the estimator interface requested in issue #145 by adding the C++ counterpart of Qiskit's Python backend_estimator_v2.py. The implementation introduces the required interface methods within backend_estimator_v2.hpp in primitives, the EstimatorPub in analogy to the SamplerPub, and supporting functionality to enable estimator-based workflows within the qiskit-cpp codebase. These changes are tested on real quantum hardware returning expectation values and associated standard deviations of a multi-term test observable, reconstructed from the run execution outcome distribution. The estimator.run() will accept an EstimatorPub and SamplerPub returning the appropriate classes. The EstimatorPub takes ISA circuits and observables.

Related issue

Closes #145

Changes made

Details, comments and testing

  • Ran backend_estimator_v2.hpp in the src/primitives folder test on ibm_kingston for expectation values of multi-term observables.
  • The expectation value of the observable H = a * ZZ + 0.5 * XI with respect to a maximally entangled state $\lvert \psi \rangle$ transpiled into an ISA circuit with a given backend
bell_state where a is 0.5 or 1.0 is calculated on the noisy ibm_kingston backend with 1000 shots to yield 0.479 +/- 0.0158955 and 0.998 +/- 0.0161848 respectively which are close to the theoretical expectation values 0.5 and 1.0.
  • To test, compile estimator_test.cpp in the samples folder to an executable, say estimator_test then
    ./estimator_test to get test output.
  • Successfully compiled the modified codebase.
  • Verified that the implementation builds without errors.
  • Performed manual testing to confirm the estimator and sampler interfaces behave consistently with the corresponding Python implementation.

AI assistance disclosure

GPT-5.5 helped inspect the function structure in backend_estimator_v2.hpp which I sourced from the Python Qiskit version backend_estimator_v2.py https://github.com/Qiskit/qiskit/blob/stable/2.4/qiskit/primitives/backend_estimator_v2.py#L170-L510, that I manually verified and tested.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 4, 2026

CLA assistant check
All committers have signed the CLA.

On using measurements to a quantum circuit.
Comment thread samples/estimator_test.cpp
Co-authored-by: Luciano Bello <766693+1ucian0@users.noreply.github.com>
@jsaroni jsaroni marked this pull request as draft June 5, 2026 23:14
@jsaroni jsaroni marked this pull request as ready for review June 5, 2026 23:15
@jsaroni
Copy link
Copy Markdown
Author

jsaroni commented Jun 6, 2026

@1uciano @doichanj, awaiting review. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implementing estimator interface

3 participants