Fix UGate docstring note about the OpenQASM 3 U definition (backport #16553) - #16774
Merged
Conversation
* Fix UGate docstring note about the OpenQASM 3 U definition The docstring claimed the matrix shown for UGate is the same as the built-in U gate in the OpenQASM 3.0 specification. The current specification defines U with an extra global phase: its matrix is exp(i*theta/2) times the matrix shown here. Update the note to state the relationship correctly, keeping the existing statement about the OpenQASM 2.0 global-phase difference. Fixes #15830 * Correct the global phase difference --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> (cherry picked from commit bf915f4)
Collaborator
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Cryoris
approved these changes
Aug 14, 2026
Coverage Report for CI Build 31793762570Coverage increased (+0.01%) to 87.751%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions6 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
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.
Summary
Fixes #15830.
The$e^{i\theta/2}$ , so the note now states the phase difference instead, using the wording suggested in the issue thread. The existing statement about the OpenQASM 2.0 phase difference is kept, since it is still correct relative to Qiskit's matrix.
UGatedocstring says its matrix is the same as the built-inUgate in the OpenQASM 3.0 specification. The current spec definesU(θ, φ, λ)as that matrix multiplied by a global phaseDetails and comments
Verified numerically: for 200 random angle triples, the spec's matrix $\tfrac{1}{2}\begin{pmatrix}1+e^{i\theta} & -ie^{i\lambda}(1-e^{i\theta})\ ie^{i\phi}(1-e^{i\theta}) & e^{i(\phi+\lambda)}(1+e^{i\theta})\end{pmatrix}$ equals$e^{i\theta/2}$ times $U_{\text{Qiskit}} = e^{i(\phi+\lambda)/2} U_{\text{OQ2}}$ also holds. Docs-only change, so no release note.
Operator(UGate(θ, φ, λ)), and the OpenQASM 2.0 relationAI disclosure: this PR was prepared with the assistance of Claude Code (Anthropic's Claude); I review and test all changes.
This is an automatic backport of pull request #16553 done by Mergify.