Repository navigation
Fix #637: Fix global phase of J-∧z decompositions - #643
Merged
Merged
Conversation
Several decompositions were only correct up to a global phase. This is harmless at top level, but `insert_control` controls these decompositions, which turns the missing global phase into a relative phase and makes the resulting controlled gate wrong. - `instruction_to_jcz` now keeps the global phase of `S`, `SDG`, `T`, `TDG`, `SX`, `SXDG`, `X` and `Z` (and therefore `Y`). - `decompose_ccx` now uses `T`, `TDG` and `S` gates as in Nielsen & Chuang instead of `RZ` rotations, which fixes controlled `CCX` and `CSWAP`. The statevector simulator ignores top-level `GPHASE` instructions, so the tests control each decomposition and compare it with `Ops.controlled`, for every instruction kind. Also fix the PR number of the CH gate entry in CHANGELOG (TeamGraphix#624, not #694) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #643 +/- ##
=======================================
Coverage 89.96% 89.97%
=======================================
Files 49 49
Lines 8462 8466 +4
=======================================
+ Hits 7613 7617 +4
Misses 849 849 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Mateo Uldemolins <m.uldemolins@gmail.com>
`Statevector.flatten` returns `Matrix`, i.e. `NDArray[object_ | complex128]`, which pyright rejects as an operand of `@`. Convert it to `complex128`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pranav97nair
approved these changes
Nov 9, 2026
pranav97nair
left a comment
Contributor
There was a problem hiding this comment.
Very nice work, thanks Thierry!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several decompositions were only correct up to a global phase. This is harmless at top level, but
insert_controlcontrols these decompositions, which turns the missing global phase into a relative phase and makes the resulting controlled gate wrong.instruction_to_jcznow keeps the global phase ofS,SDG,T,TDG,SX,SXDG,XandZ(and thereforeY).decompose_ccxnow usesT,TDGandSgates as in Nielsen & Chuang instead ofRZrotations, which fixes controlledCCXandCSWAP.The statevector simulator ignores top-level
GPHASEinstructions, so the tests control each decomposition and compare it withOps.controlled, for every instruction kind.Also fix the PR number of the CH gate entry in CHANGELOG (#624, not #694).