-
Notifications
You must be signed in to change notification settings - Fork 70
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
Layout of transpiled circuit is not being applied to the operators #611
Comments
Thank you for the very clear description of this bug @felipelewyee !! I don't know if we'll have the time to fix this before the next release (which will likely be next week) but we'll do our best to fix it very soon and keep you updated. Thanks again. |
Hi @felipelewyee, Thanks again for reporting this bug. Our team has reviewed it and they liked your suggestion for the fix. Would you like to open a Pull Request (PR) for the fix? Make sure the PR is targeting master. If this is your first PR let us know and we can guide you through the process. On the other hand, if you prefer that we make the PR (instead of opening it yourself) we can do it. Just let us know what you prefer. |
Hi, thanks for checking my report. I am opening the PR in a moment. |
I have done the PR. Let me know if something is needed, and thanks in advance. |
Describe the bug
The layout of the transpiled circuit is not being applied to the observables, leading to wrong results when it differs from the layout of the original circuit. This can be solved by adding
as line 657 of "_execute_estimator" in qiskit_device.py, and modifying line 663 to be:
To Reproduce
The result of the following minimal circuit should be close to 1, but instead the circuit execution gives close to 0. (I have used optimization_level=2 to allow the layout to change in transpilation. Using optimization_level=0 produce the right result for this circuit as the layout is not changed.)
Expected behavior
Layout of transpiled circuit should be applied to the operators.
Screenshots
I have added some prints as reference:
It can be seen that the layout has changed in transpilation
The Pauli observable has the layout of the original circuit, while the compiled observable has the correct Layout and gives an expectation value close to 1 (the correct result).
Version (qml.about()):
Name: PennyLane
Version: 0.39.0
Platform info: Linux-6.11.0-13-generic-x86_64-with-glibc2.40
Python version: 3.10.0
Numpy version: 2.0.2
Scipy version: 1.15.0
Installed devices:
The text was updated successfully, but these errors were encountered: