-
Notifications
You must be signed in to change notification settings - Fork 564
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
[BUG] Some decompositions/transforms do not preserve derivatives #5715
Labels
bug 🐛
Something isn't working
Comments
While trying to fix this, I noticed that |
dwierichs
added a commit
that referenced
this issue
Jun 13, 2024
**Context:** The decomposition of `MottonenStatePreparation` skips some gates for special parameter values/input states. See the linked issue for details. **Description of the Change:** This PR introduces a check for differentiability so that the gates only are skipped when no derivatives are being computed. Note that this does *not* fix the non-differentiability at other special parameter points that also is referenced in #5715 and that is being warned against in the docs already. Also, the linked issue is about multiple operations and we here only address `MottonenStatePreparation`. **Benefits:** Fixes parts of #5715. Unblocks #5620 . **Possible Drawbacks:** **Related GitHub Issues:** #5715
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Using decompositions and transforms does not change the derivative of the overall workflow.
Actual behavior
Some decompositions/transforms only reproduce the function, but not its derivative. I found this in the following parts of the codebase:
merge_rotations
: Some rotation gates are skipped for zero anglessingle_qubit_fusion
: Some rotation gates are skipped for zero anglesMottonenStatePreparation
: Depending on the input state, gates are skipped, which leads to errors with JITting (no gradient entries to stack) or producesnan
values.fuse_rot_angles
: Used inmerge_rotations
andsingle_qubit_fusion
, creates second bugs within both functionsAdditional information
Note that JITting usually prevents the source of error (except for
MottonenStatePrep
), and in all examples above, the code base has special logic for JITting.As a consequence, JITted derivatives tend to be unaffected by the type of bug observed in the transforms.
Under the hood, this seems like similar to #5541, which is concerned with
AmplitudeEmbedding
and is being solved in #5620 by modifying the diff method ofGlobalPhase
. However, the bug described here is of different origin and was encountered while finalizing the tests for #5620 forMottonenStatePreparation
.Source code
Tracebacks
No response
System information
Existing GitHub issues
The text was updated successfully, but these errors were encountered: