Uh oh!
There was an error while loading. Please reload this page.
Fix pretty-printing of Clifford gates - #576
Merged
thierry-martinez merged 5 commits intoAug 18, 2026
Merged
Conversation
This commit implements `clifford_to_str`, which relies on the QASM3 decomposition (into `I`, `X`, `Y`, `Z`, `S`, `S†`, and `H`), since it is more compact than the HSZ decomposition. `CLIFFORD_LABEL` is removed from `_db` as names were ambiguous. The QASM3 decomposition has been made optimal and is now tested. All members of the `Clifford` class now appear in the documentation and docstrings are fixed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## master #576 +/- ##
=======================================
Coverage 89.26% 89.27% =======================================
Files 49 49 Lines 7791 7798 +7 =======================================
+ Hits 6955 6962 +7
Misses 836 836 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
matulni
reviewed
Aug 12, 2026
Comment on lines
+158
to
+177
| def generate_qasm3_decomposition() -> tuple[tuple[str, ...], ...]: | ||
| decompositions: list[tuple[str, ...] | None] = [None] * len(Clifford) | ||
| new_decompositions: dict[Clifford, tuple[str, ...]] = { | ||
| clifford: (instr,) for clifford, instr in QASM3_BASIS.items() | ||
| } | ||
| while new_decompositions: | ||
| current_decompositions = new_decompositions | ||
| new_decompositions = {} | ||
| for clifford, decomposition in current_decompositions.items(): | ||
| decompositions[clifford.value] = decomposition | ||
| for clifford, decomposition in current_decompositions.items(): | ||
| for instr_clifford, instr in QASM3_BASIS.items(): | ||
| result = instr_clifford @ clifford | ||
| if decompositions[result.value] is not None: | ||
| continue | ||
| result_decomposition = (*decomposition, instr) | ||
| decompositions[result.value] = result_decomposition | ||
| new_decompositions[result] = result_decomposition | ||
| assert all(decomposition is not None for decomposition in decompositions) | ||
| return tuple(map(unwrap, decompositions)) |
CollaboratorAuthor
There was a problem hiding this comment.
Seeing the code again, I realized that lines 167 and 174 are making the job twice. Fixed in 21590b2. Thanks for the compliment!
pranav97nair
approved these changes
Aug 18, 2026
pranav97nair
left a comment
Contributor
There was a problem hiding this comment.
Nice work, thanks Thierry!
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
This commit implements
clifford_to_str, which relies on the QASM3 decomposition (intoI,X,Y,Z,S,S†, andH), since it is more compact than the HSZ decomposition.CLIFFORD_LABELis removed from_dbas names were ambiguous. The QASM3 decomposition has been made optimal and is now tested.All members of the
Cliffordclass now appear in the documentation and docstrings are fixed.