-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify decomposition of controlled eigengates with global phase #7383
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
Simplify decomposition of controlled eigengates with global phase #7383
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7383 +/- ##
=======================================
Coverage 98.69% 98.69%
=======================================
Files 1112 1112
Lines 98076 98152 +76
=======================================
+ Hits 96798 96875 +77
+ Misses 1278 1277 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…7405) This addresses an issue I found while working on #7291 Currently `merge_single_qubit_moments_to_phxz` will not merge moments that have a global phase, meaning that moments that could theoretically be merged are not. I updated it so that global phase is also supported. I added two tests to show the issue. Perhaps this situation is not common right now, but if #7383 is committed and the flag is used, it may become more common. @daxfohl Note that I'm not merging the global phase operations in a single one, because I'm thinking some phases could be parametrized; should I attempt to do this?
…uantumlib#7405) This addresses an issue I found while working on quantumlib#7291 Currently `merge_single_qubit_moments_to_phxz` will not merge moments that have a global phase, meaning that moments that could theoretically be merged are not. I updated it so that global phase is also supported. I added two tests to show the issue. Perhaps this situation is not common right now, but if quantumlib#7383 is committed and the flag is used, it may become more common. @daxfohl Note that I'm not merging the global phase operations in a single one, because I'm thinking some phases could be parametrized; should I attempt to do this?
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.
overall LGTM%nits
Co-authored-by: Noureldin <noureldinyosri@gmail.com>
Co-authored-by: Noureldin <noureldinyosri@gmail.com>
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 @daxfohl
…antumlib#7383) Fixes quantumlib#7238 1. Create a flag in `DecomposeContext` to configure extraction of terminal gates' global phases into distinct GlobalPhaseGates. a. This flag defaults to False for backward compatibility. 2. Instrument the terminal decomposition gates (X, Y, Z, CZ) to check this flag and extract global phase if it exists. a. Added some convenience methods in GlobalPhaseGate to help. b. Updated some unrelated existing code to use these convenience methods for clarity. 3. Update `ControlledGate.decompose` to attempt decompose the subgate before attempting the brute-force approach. a. This is what ultimately simplifies the decomposition result. b. Step 2 also allowed removal of the entire CZPowGate instanceof block there, since it was about extracting global phase. 4. Add unit tests for each change. --------- Co-authored-by: Noureldin <noureldinyosri@gmail.com>
…uantumlib#7405) This addresses an issue I found while working on quantumlib#7291 Currently `merge_single_qubit_moments_to_phxz` will not merge moments that have a global phase, meaning that moments that could theoretically be merged are not. I updated it so that global phase is also supported. I added two tests to show the issue. Perhaps this situation is not common right now, but if quantumlib#7383 is committed and the flag is used, it may become more common. @daxfohl Note that I'm not merging the global phase operations in a single one, because I'm thinking some phases could be parametrized; should I attempt to do this?
…antumlib#7383) Fixes quantumlib#7238 1. Create a flag in `DecomposeContext` to configure extraction of terminal gates' global phases into distinct GlobalPhaseGates. a. This flag defaults to False for backward compatibility. 2. Instrument the terminal decomposition gates (X, Y, Z, CZ) to check this flag and extract global phase if it exists. a. Added some convenience methods in GlobalPhaseGate to help. b. Updated some unrelated existing code to use these convenience methods for clarity. 3. Update `ControlledGate.decompose` to attempt decompose the subgate before attempting the brute-force approach. a. This is what ultimately simplifies the decomposition result. b. Step 2 also allowed removal of the entire CZPowGate instanceof block there, since it was about extracting global phase. 4. Add unit tests for each change. --------- Co-authored-by: Noureldin <noureldinyosri@gmail.com>
Fixes #7238
DecomposeContext
to configure extraction of terminal gates' global phases into distinct GlobalPhaseGates.a. This flag defaults to False for backward compatibility.
a. Added some convenience methods in GlobalPhaseGate to help.
b. Updated some unrelated existing code to use these convenience methods for clarity.
ControlledGate.decompose
to attempt decompose the subgate before attempting the brute-force approach.a. This is what ultimately simplifies the decomposition result.
b. Step 2 also allowed removal of the entire CZPowGate instanceof block there, since it was about extracting global phase.