Skip to content

Fix UGate docstring note about the OpenQASM 3 U definition (backport #16553) - #16774

Merged
Cryoris merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16553
Aug 14, 2026
Merged

Fix UGate docstring note about the OpenQASM 3 U definition (backport #16553)#16774
Cryoris merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16553

Conversation

@mergify

@mergify mergify Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #15830.

The UGate docstring says its matrix is the same as the built-in U gate in the OpenQASM 3.0 specification. The current spec defines U(θ, φ, λ) as that matrix multiplied by a global phase $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.

Details 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 Operator(UGate(θ, φ, λ)), and the OpenQASM 2.0 relation $U_{\text{Qiskit}} = e^{i(\phi+\lambda)/2} U_{\text{OQ2}}$ also holds. Docs-only change, so no release note.

AI 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.

* 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)
@mergify
mergify Bot requested a review from a team as a code owner August 14, 2026 10:49
@mergify
mergify Bot requested a review from jakelishman August 14, 2026 10:49
@qiskit-bot

Copy link
Copy Markdown
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
  • @Qiskit/terra-core
  • @ajavadia

@github-actions github-actions Bot added documentation Something is not clear or an error documentation Changelog: None Do not include in the GitHub Release changelog. Community PR PRs from contributors that are not 'members' of the Qiskit repo labels Aug 14, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31793762570

Coverage increased (+0.01%) to 87.751%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 6 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

6 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/lex.rs 3 92.8%
crates/circuit/src/parameter/symbol_expr.rs 2 77.03%
crates/circuit/src/parameter/parameter_expression.rs 1 90.36%

Coverage Stats

Coverage Status
Relevant Lines: 128896
Covered Lines: 113107
Line Coverage: 87.75%
Coverage Strength: 998159.99 hits per line

💛 - Coveralls

@Cryoris
Cryoris added this pull request to the merge queue Aug 14, 2026
Merged via the queue into stable/2.5 with commit 6784962 Aug 14, 2026
55 of 58 checks passed
@Cryoris
Cryoris deleted the mergify/bp/stable/2.5/pr-16553 branch August 14, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: None Do not include in the GitHub Release changelog. Community PR PRs from contributors that are not 'members' of the Qiskit repo documentation Something is not clear or an error documentation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants