Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EstimatorQNN/SamplerQNN with BaseEstimatorV2/BaseSamplerV2 #840

Closed
ksk0629 opened this issue Oct 18, 2024 · 7 comments · Fixed by #843
Closed

EstimatorQNN/SamplerQNN with BaseEstimatorV2/BaseSamplerV2 #840

ksk0629 opened this issue Oct 18, 2024 · 7 comments · Fixed by #843
Labels
Hardware runtime 💻 Running jobs on IBM quantum devices type: question 🙋 Question about the code or its uses
Milestone

Comments

@ksk0629
Copy link

ksk0629 commented Oct 18, 2024

Is there any way to use BaseEstimatorV2/BaseSamplerV2 with EstimatorQNN/SamplerQNN at the moment?

@edoaltamura
Copy link
Collaborator

edoaltamura commented Oct 18, 2024

Hi @ksk0629, it depends.

  • In simulations (e.g. Qiskit Aer) you can already use V2 primitives by importing the correct class from Qiskit like from qiskit.primitives.base import BaseEstimatorV2 and passing an instance of it in EstimatorQNN(estimator=...). Similarly, you can do this for the Sampler.

  • If you want to run on a real IBM backend, EstimatorQNN or SamplerQNN are not supported at the moment with V2 primitives (Remove V1 support Qiskit/qiskit-ibm-runtime#1857). However, Qiskit Machine Learning v.0.8 will support V2 primitives, with initial release expected at the end of October 2024, see https://github.com/qiskit-community/qiskit-machine-learning/milestone/4.

Does this answer your question?

@edoaltamura edoaltamura added type: question 🙋 Question about the code or its uses Hardware runtime 💻 Running jobs on IBM quantum devices labels Oct 18, 2024
@ksk0629
Copy link
Author

ksk0629 commented Oct 18, 2024

Hi @edoaltamura,
I appreciate your answer!

I am sorry that I am not able to provide the error at the moment, but I think qiskit_aer.primitives.EstimatorV2, which inherits from BaseEstimatorV2, is incompatible with EstimatorQNN. It is no problem to give it to EstimatorQNN as the estimator parameter. However, when you start to fit the EstiamtorQNN an error happens on the run (or _run) function. To the best of my recollection, it was about the number of parameters and indeed was different according to the implementation.

But,

However, Qiskit Machine Learning v.0.8 will support V2 primitives, with initial release expected at the end of October 2024, see https://github.com/qiskit-community/qiskit-machine-learning/milestone/4.

This is quite exciting news indeed. I appreciate you informing the article :)

@ksk0629
Copy link
Author

ksk0629 commented Nov 5, 2024

Just curious and maybe here is not the right place to ask this, but how is v0.8.0 going?

@OkuyanBoga
Copy link
Collaborator

Hi @ksk0629, you can check our fork branch. It is still getting tested for V2 primitives, and for 0.8.0, our plan is to support both V1 and V2 primitives, and deprecate V1 in the following updates. Currently, it is almost finalised, but, we need to prepare it before the release.

Hope this helps.

The delay is caused by the deprecation of qiskit-algorithms library.

@edoaltamura edoaltamura added this to the 0.8.0 milestone Nov 8, 2024
@ksk0629
Copy link
Author

ksk0629 commented Nov 8, 2024

Hi @OkuyanBoga, thank you for sharing your fork branch with me and additional information. Understood. I'm looking forward to using the new version :)

@edoaltamura
Copy link
Collaborator

Just a note that #843 will close this issue and should resolve the problem. Looking forward to hearing your feedback on the V2 primitive update @ksk0629!

@OkuyanBoga
Copy link
Collaborator

Hi @ksk0629, I hope the new release helps.

If you find any issue, or even want to fix those or if you want to add new functionality, please feel free to submit an issue or a pull request, we are open to any contribution. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware runtime 💻 Running jobs on IBM quantum devices type: question 🙋 Question about the code or its uses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants