qiskit-community / qiskit-machine-learning

Quantum Machine Learning
https://qiskit-community.github.io/qiskit-machine-learning/
Apache License 2.0
693 stars 328 forks source link

EstimatorQNN/SamplerQNN with BaseEstimatorV2/BaseSamplerV2 #840

Closed ksk0629 closed 1 week ago

ksk0629 commented 1 month ago

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

edoaltamura commented 1 month ago

Hi @ksk0629, it depends.

Does this answer your question?

ksk0629 commented 1 month ago

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 commented 2 weeks ago

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

OkuyanBoga commented 2 weeks ago

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.

ksk0629 commented 2 weeks ago

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 commented 2 weeks ago

Just a note that https://github.com/qiskit-community/qiskit-machine-learning/pull/843 will close this issue and should resolve the problem. Looking forward to hearing your feedback on the V2 primitive update @ksk0629!

OkuyanBoga commented 1 week ago

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. :)