-
Notifications
You must be signed in to change notification settings - Fork 327
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
pass_manager param in EstimatorQNN generates error for V2 estimator on statevector simulator #872
Comments
Hi @ironfrown, thank you very much for the feedback. Unfortunately, there are too many different V2 primitives available to check and bug-fix after a qiskit update, hopefully, new release will solve this issue. Can you please check and confirm if it still exists with 0.8.1? |
Hi @OkuyanBoga, unfortunately ML 0.8.1 has not addressed all issues. Here are some example runs on a simple "raw" circuit of ZZFeatureMap + TwoLocal with V2 primitives estimator and SparsePauliOp observables:
It seems that EstimatorQNN is now a complex class, which may be a challenge for the Qiskit ML novices! |
@OkuyanBoga, note however that adding measurements to the parameterised circuit (as recommended in the migration guide) and training it with EstimatorQNN + NeuralNetworkRegressor makes its processing impossibly slow! |
Hi @ironfrown, thanks again for the feedback. Unfortunately, updates from Qiskit make it challenging even for us, and we are trying our best to reduce the effect on the end users. I strongly suggest using Qiskit<1.3 for now due to issues in Qiskit 1.3 and Qiskit-Aer. In Qiskit 1.3, circuits such as ZZFeatureMap are replaced with functions such as zzfeaturemap, and we are not supporting functions yet. If you are not using Qiskit 1.3, can you please share your code to reproduce the first two issues? I think the raw circuits should not fail the check for qiskit-machine-learning/qiskit_machine_learning/neural_networks/estimator_qnn.py Lines 178 to 185 in 94ccb0a
We plan to do another bug-fix update (0.8.2) before the new year, so we can address all of these as much as possible. Unfortunately, we are also experiencing performance issues with every V2 primitive, especially when using transpilation. We think this issue stems from gradients when gradient algorithms create new circuits and tranpile them each step. We are planning to speed up the process in the following major release (0.9). |
@OkuyanBoga, I am using Qiskit 1.2.4 and installed ML 0.8.1. The code attached in the section "How can we reproduce the issue?" demonstrates the first two issues. When you run it as is, it shows the layout error (problem 2), i.e. use:
When you comment out the "pass_manager=pm" line in EstimatorQNN class call, it demonstrates the 'unknown instruction: ZZFeatureMap' issue (problem 1), i.e. use:
When you pass the pass-manager preprocessed circuit and comment out the pass_manager option, it works fine (the last point), i.e. use:
Note that using the pass manager option in gradient does not change these errors. |
Thanks @ironfrown.
Unfortunately, the lack of standards in V2 primitives can be really frustrating. We tried to minimise this in Qiskit ML for end users. I don't think there is an issue with the algorithm, but we will check if we can add checks based on the given estimator. |
@OkuyanBoga, I thought you wanted to replicate the errors - just run the provided script and see the results, you can change the options to what you think should be correct! |
Inclusion of pass_manager=pm in the gradient makes no difference, the errors will show! Note also that inclusion of pass_manager in gradient for circuits with many parameters leads to the exponential memory use and the system crash. |
@ironfrown I am kindly trying to help by any means, it could be by replicating and fixing the errors or correcting the way algorithms run. If you identify any potential improvements, we welcome you to submit a pull request. Any contributions are very welcome. As I mentioned before, this problem arises from the lack of standards in V2 primitives, backends and transpilers between qiskit, qiskit-aer, qiskit-ibm-runtime, and we will add checks based on the given estimator to fix the issue for the upcoming minor release 0.8.2. We are also working on improving gradients with transpilation, it will be included in the next major release. You can add a layout to the pass manager to temporarily fix the issue : |
Environment
What is happening?
I am running EstimatorQNN with V2 AerEstimator (and 'statevector' and 'GPU' options), on a simple circuit (ZZFeatureMap+RealAmplitudes). When the circuit has been processed by generate_preset_pass_manager before calling EstimatorQNN, it works fine. When a "raw" circuit has been passed into EstimatorQNN with a pass_manager option, it fails as it expects the circuit to have a non-empty layout (which is None). The error is:
How can we reproduce the issue?
What should happen?
Supplied pass manager should be applied to the "raw" circuit without errors
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: