Closed ksk0629 closed 1 week ago
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 (https://github.com/Qiskit/qiskit-ibm-runtime/issues/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?
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 :)
Just curious and maybe here is not the right place to ask this, but how is v0.8.0 going?
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.
Hi @OkuyanBoga, thank you for sharing your fork branch with me and additional information. Understood. I'm looking forward to using the new version :)
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!
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. :)
Is there any way to use BaseEstimatorV2/BaseSamplerV2 with EstimatorQNN/SamplerQNN at the moment?