-
Notifications
You must be signed in to change notification settings - Fork 603
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
Fix the derivative of MottonenStatePreparation
where possible
#5774
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5774 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.01%
==========================================
Files 420 420
Lines 40138 39846 -292
==========================================
- Hits 40010 39716 -294
- Misses 128 130 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small suggestion regarding skipping test cases, otherwise LGTM!
tests/templates/test_state_preparations/test_mottonen_state_prep.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! happy to approve once I cleared up a couple of doubts
First of all, I would like to make sure. The derivative of a function with real output (as an expected value), can it give a complex number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I answered both the complex numbers and precision issues in the comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarifications! Ready to go 🚀
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