-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Parameter table not updated after circuit assignment #6633
Comments
Thanks for the report! I believe we had similar issues with append/compose but fixed them there as they are the primary methods for modifying the circuit. @kdk Since the data attribute is used a lot internally (e.g. to append) do you have an idea of whether adding a parameter table update here could have a performance impact? If no it might be good that we add a safeguard, otherwise we should maybe just clearly state that it doesn't handle the parameters properly 🤔 |
The fix here shouldn't have a substantial performance impact. All of our existing tooling ( In https://github.com/Qiskit/qiskit-terra/blob/2eee566/qiskit/circuit/quantumcircuitdata.py#L59 , we already update the (It would be good if at the same time we can update |
Can I work on this problem ? |
Sure thing, assigned to you @TakahitoMotoki! Ler us know if you need any help 😄 |
Thank you very much ,@javabster ! |
I have one question about a code test. According to CONTRIBUTING.md, I need to run "tox -epy310" and "tox -elint" to check soundness and style of the modified code. However, it seems that I cannot run tox command since my laptop is Macbook Pro with ARM processor. |
Hi @TakahitoMotoki I'm not aware that ARM processors cause issues with tox. As we currently don't yet support 3.10 I'd recommend trying Also might be worth making sure you have tox installed 😄 |
@javabster However, I still got an error when executing "tox -epy39". Followings are error messages. python version: 3.9.7 RuntimeError: This version of jaxlib was built using AVX instructions, which your CPU and/or operating system do not support. You may be able work around this issue by building jaxlib from source. ================================================================================ |
ok so this looks like an issue with jax not tox. It seems others have had the same issue, you could try some of the solutions people have mentioned here: jax-ml/jax#5501 |
@javabster |
@javabster I could solve the jax problem above (I could pass the tox test!) and finally created a pull request. I am really grateful for your help. |
Could I please try and fix the code? I am a newbie but I would like to try and learn. |
I don't know if this will reach anyone on here but I think it was an issue of control and target. Code: theta = Parameter('$\theta$') for idx, (instr, qargs, cargs) in enumerate(qc.data): print(qc) %matplotlib inline P.S. The only thing I added here was the 8th line and the mpl plot. |
Information
What is the current behavior?
When performing a circuit assignment,
_parameter_table
is not updated to remove the discarded instruction, causing certain methods to fail (i.e.,.copy()
).Steps to reproduce the problem
prints
Now, modify circuit by assignment in some way, for example by adding a control to the
RZGate
:prints
Note that there are two instructions in the parameter table, one corresponding to
CRZGate
that was assigned, and the originalRZGate
that is no longer in the circuit. This causes errors when trying to map between parameter tables, for example the.copy()
method:prints
In this case, we see that the error was caused by instruction 140722385862320, which corresponds to the original
RZGate
instruction.What is the expected behavior?
The parameter table should be updated upon assignment.
Suggested solutions
Remove overwritten instructions from the parameter table.
The text was updated successfully, but these errors were encountered: