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 handling of cumulative_angles in merge_rotations #7011

Merged
merged 12 commits into from
Feb 28, 2025

Conversation

andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Feb 26, 2025

Context:

For the Rot gate, the angles can cancel in a non-trivial way (e.g. Rot(φ,0,-φ) = RZ(φ) RY(0) RZ(-φ) = RZ(0) = I).

Unlike single_qubit_fusion, this was not being handled correctly and only the trivial case where all angles are zero was being checked.

Description of the Change:

  • Create a boolean flag angles_cancel that determines whether the operator is the identity and can be ignored in the transformed tape.
  • Added a test to cover the use case.

Benefits: Correct behaviour.

Possible Drawbacks: None identified.

Related GitHub Issues: Fixes #7010

[sc-85327]

This comment was marked as resolved.

@albi3ro albi3ro self-requested a review February 26, 2025 19:32
@dwierichs dwierichs self-requested a review February 26, 2025 19:32
@andrijapau
Copy link
Contributor Author

@albi3ro, @dwierichs

I've deleted the xfaild test associated with this issue #7009 after the discussion that this is expected behaviour for the merge_rotations transform. 👍🏼

Copy link
Contributor

@dwierichs dwierichs left a comment

Choose a reason for hiding this comment

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

Just had a minor suggestion for readability, otherwise LGTM 🚀
Thanks for this upgrade @andrijapau 🎉

@andrijapau andrijapau changed the title Fix handling of cumalative_angles in merge_rotations Fix handling of cumulative_angles in merge_rotations Feb 26, 2025
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.60%. Comparing base (a0f6f71) to head (743f737).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7011   +/-   ##
=======================================
  Coverage   99.60%   99.60%           
=======================================
  Files         485      485           
  Lines       46361    46365    +4     
=======================================
+ Hits        46178    46182    +4     
  Misses        183      183           

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

@andrijapau andrijapau enabled auto-merge (squash) February 28, 2025 21:57
@andrijapau andrijapau merged commit 4690439 into master Feb 28, 2025
46 checks passed
@andrijapau andrijapau deleted the fix-merge-rot-bug branch February 28, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance Rot gates merging in merge_rotations transform
3 participants