-
Notifications
You must be signed in to change notification settings - Fork 53
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
IAE works differently for sampler from Aer and Sampler from qiskit ibm runtime. #71
Comments
Hi! I have not been able to reproduce your bug. I filled in your snippets with the necessary imports but the algorithm raises an unexpected error. It would help a lot if you could provide a single complete snippet that I could copy-paste and run to reproduce the behavior you saw (the runtime one is enough, no need for another snippet for the aer sampler). |
sure
then making the quantum circuit:
Then after the ciruit is made :
and then checking the result:
It will give out a result of Now for the runtime part:
The same code for the Quantum Circuit i.e
This time the backend is:
and then setting the options:
and finally running the circuit:
This will yield a result of around |
I have also uploaded it here : https://github.com/sirgeorgesawcon/test/blob/main/Copy_of_Error_Issue.ipynb |
Thanks a lot @sirgeorgesawcon. It turns out that the serialization module used to send the information over to the runtime server does not deal well with opaque parameterized instructions such as the multi-controlled RY gates you are using. I will open an issue in qiskit to expose the bug, but in the meantime you can work around the issue if you transpile your circuit before creating your
Let me know if this works for you :) I tried it out in my environment and got |
See issue here: Qiskit/qiskit#10735 |
Hi @ElePT , thank you for you help. Yes the code works now. |
Issue fixed in Qiskit/qiskit#10758 :) The change will not be deployed in the runtime environment at least until qiskit's next bugfix release, so it might take some time to see it fixed in the Sampler. |
Environment
What is happening?
Describe the bug : I am working on an Iterative Amplitude Estimation routine that works on sampler. I have a quantum circuit, that I run first using the
sampler
fromaer
, I import it from there, simply setsampler = _Sampler(run_options={"shots": num_shots})
and run the algorithm, It gives me a result of
0.64165
which is very near to what I shoud be getting (i verified it using classical caluclations , it should be around0.64
)Then I use
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Estimator, Options
where my
qiskit_ibm_runtime
version is0.11.3
Then I run the exact same quantum circuit
qc
, usingbackend = "ibmq_qasm_simulator"
options = Options()
options.execution.shots = 2000
options.resilience_level = 0
and then invoke the session and make use of
sampler = Sampler(options=options)
The result I'm getting from this is never the same, and is no where close to my answer that I was getting using
aer
Sampler.Even though the backend I'm using is
IBM_Qasm_simulator
, which is error free and ideal simulator, so there should not be any error in the result, but I'm not able to replicate the result that I was getting using theaer
sampler. Why is it so? Since both these make use of shot-type backend, the only difference is that one is running on my local device and the other on IBM cloud. But the answers are so different.Suggested solutions :
Additional Information : I also had a lengthy conversation on Qiskit's slack as well on this said topic
Slack Chat: https://qiskit.slack.com/archives/C7SJ0PJ5A/p1693194989748429?thread_ts=1693194989.748429&cid=C7SJ0PJ5A
How can we reproduce the issue?
Steps to reproduce :
Here's the code for the quantum circuit
Once the quantum circuit
qc
is made, first we importsampler
from :from qiskit_aer.primitives import Sampler
Then call the IAE function:
and then:
The result for the final print command is
0.641
But then, when i make use of :
and then set the
backend
:backend = "ibmq_qasm_simulator"
and then the
options
and finally calling the IAE:
always give me a different result from what is Intended.
What should happen?
Expected behavior : I expect to see the same behaviour as I was seeing from the aer sampler in qiskit ibm runtime sampler.
Any suggestions?
I already discussed this issue on Slack : https://qiskit.slack.com/archives/C7SJ0PJ5A/p1693194989748429?thread_ts=1693194989.748429&cid=C7SJ0PJ5A
and also opened an Issue in qiskit-ibm-runtime and they suggested to open an issue here,
Qiskit/qiskit-ibm-runtime#1043
The text was updated successfully, but these errors were encountered: