Skip to content
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 derivatives of merge_rotations and single_qubit_fusion #6033

Merged
merged 41 commits into from
Aug 19, 2024

Conversation

dwierichs
Copy link
Contributor

Context:
As reported in #5715, merge_rotations and single_qubit_fusion have problems with differentiability at specific points.
#6031 takes care of upgrading the Rot-angle fusion to only ever return NaNs at mathematically non-differentiable points, rather than wrong results.
However, the transforms add additional points, based on internal optimizations, where the derivative is flawed.

Description of the Change:
This PR fixes the flawed derivatives caused by the code of the transforms themselves.

Benefits:
Fixes derivatives of merge_rotations and single_qubit_fusion (where mathematically defined)

Possible Drawbacks:
N/A

Related GitHub Issues:
Fixes another part of #5715, still not all of it.

@dwierichs dwierichs changed the base branch from master to rot_math July 24, 2024 12:14
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (edda2e9) to head (12fbf15).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6033      +/-   ##
==========================================
- Coverage   99.66%   99.65%   -0.01%     
==========================================
  Files         432      432              
  Lines       41996    41691     -305     
==========================================
- Hits        41855    41549     -306     
- Misses        141      142       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
dwierichs and others added 11 commits July 25, 2024 22:31
Co-authored-by: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR @dwierichs . Looks good to me! I'm suggesting a couple changes, which you can accept or reject as you see fit.

pennylane/transforms/optimization/merge_rotations.py Outdated Show resolved Hide resolved
pennylane/transforms/optimization/merge_rotations.py Outdated Show resolved Hide resolved
@dwierichs dwierichs requested a review from a team as a code owner August 7, 2024 10:32
@dwierichs dwierichs requested review from Qottmann and removed request for a team August 7, 2024 10:33
@Qottmann
Copy link
Contributor

Qottmann commented Aug 7, 2024

Is this targeting the correct base branch as is? 😬
image

@dwierichs
Copy link
Contributor Author

Haha, sorry @Qottmann . Yes the base branch is right, but I merged master into both branches, but only pushed it here and not on the rot_math branch. Apologies, fixed now!

Copy link
Contributor

@Qottmann Qottmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @dwierichs

Don't see anything suspicious and appreciate the simplifications of the code.

@dwierichs dwierichs added the merge-ready ✔️ All tests pass and the PR is ready to be merged. label Aug 8, 2024
Base automatically changed from rot_math to master August 14, 2024 18:22
@dwierichs dwierichs enabled auto-merge (squash) August 19, 2024 07:05
@dwierichs dwierichs merged commit 3543cef into master Aug 19, 2024
40 checks passed
@dwierichs dwierichs deleted the fix_merge_rotations branch August 19, 2024 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-ready ✔️ All tests pass and the PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants