Skip to content
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

Add documentation on OpenQASM 2 phase conventions #10801

Merged
merged 3 commits into from
Sep 28, 2023

Conversation

jakelishman
Copy link
Member

Summary

OpenQASM 2 as a language does not provide a way to specify global phases, either of operations or the entire program. The prose of the defining paper talks about the u1 and rz instructions from qelib1.inc as having different global phases, however since the language cannot represent this, the header file defines rz apparently as a direct alias to u1.

Qiskit's position has always been that we interpret rz as using the phase convention of RZGate, and u1 uses the different convention of PhaseGate. This commit adds documentation to the pages on OpenQASM 2 about this difference, and includes an example of how to override Qiskit's default if the generating code (e.g. pyZX) wants to use an alternative phase convention.

Details and comments

See the discussion in #10790.

Also I fixed a couple of typos that have been annoying me in the documentation, since I had it open.

OpenQASM 2 as a language does not provide a way to specify global
phases, either of operations or the entire program.  The prose of the
defining paper talks about the `u1` and `rz` instructions from
`qelib1.inc` as having different global phases, however since the
language cannot represent this, the header file defines `rz` apparently
as a direct alias to `u1`.

Qiskit's position has always been that we interpret `rz` as using the
phase convention of `RZGate`, and `u1` uses the different convention of
`PhaseGate`.  This commit adds documentation to the pages on OpenQASM 2
about this difference, and includes an example of how to override
Qiskit's default if the generating code (e.g. pyZX) wants to use an
alternative phase convention.
@jakelishman jakelishman added documentation Something is not clear or an error documentation stable backport potential The bug might be minimal and/or import enough to be port to stable mod: qasm2 Relating to OpenQASM 2 import or export Changelog: None Do not include in changelog labels Sep 8, 2023
@jakelishman jakelishman requested a review from a team as a code owner September 8, 2023 17:45
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me 👍🏻

@jakelishman jakelishman added this pull request to the merge queue Sep 28, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 28, 2023
@jakelishman jakelishman added this pull request to the merge queue Sep 28, 2023
Merged via the queue into Qiskit:main with commit 10461f1 Sep 28, 2023
14 checks passed
@jakelishman jakelishman deleted the qasm2/phase-conventions branch September 28, 2023 16:03
mergify bot pushed a commit that referenced this pull request Sep 28, 2023
* Add documentation on OpenQASM 2 phase conventions

OpenQASM 2 as a language does not provide a way to specify global
phases, either of operations or the entire program.  The prose of the
defining paper talks about the `u1` and `rz` instructions from
`qelib1.inc` as having different global phases, however since the
language cannot represent this, the header file defines `rz` apparently
as a direct alias to `u1`.

Qiskit's position has always been that we interpret `rz` as using the
phase convention of `RZGate`, and `u1` uses the different convention of
`PhaseGate`.  This commit adds documentation to the pages on OpenQASM 2
about this difference, and includes an example of how to override
Qiskit's default if the generating code (e.g. pyZX) wants to use an
alternative phase convention.

* Comment on the number of overrides needed

Co-authored-by: Julien Gacon <gaconju@gmail.com>

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
(cherry picked from commit 10461f1)
@jakelishman jakelishman modified the milestones: 0.25.2, 0.25.3 Sep 28, 2023
github-merge-queue bot pushed a commit that referenced this pull request Sep 28, 2023
* Add documentation on OpenQASM 2 phase conventions

OpenQASM 2 as a language does not provide a way to specify global
phases, either of operations or the entire program.  The prose of the
defining paper talks about the `u1` and `rz` instructions from
`qelib1.inc` as having different global phases, however since the
language cannot represent this, the header file defines `rz` apparently
as a direct alias to `u1`.

Qiskit's position has always been that we interpret `rz` as using the
phase convention of `RZGate`, and `u1` uses the different convention of
`PhaseGate`.  This commit adds documentation to the pages on OpenQASM 2
about this difference, and includes an example of how to override
Qiskit's default if the generating code (e.g. pyZX) wants to use an
alternative phase convention.

* Comment on the number of overrides needed

Co-authored-by: Julien Gacon <gaconju@gmail.com>

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
(cherry picked from commit 10461f1)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
rupeshknn pushed a commit to rupeshknn/qiskit that referenced this pull request Oct 9, 2023
* Add documentation on OpenQASM 2 phase conventions

OpenQASM 2 as a language does not provide a way to specify global
phases, either of operations or the entire program.  The prose of the
defining paper talks about the `u1` and `rz` instructions from
`qelib1.inc` as having different global phases, however since the
language cannot represent this, the header file defines `rz` apparently
as a direct alias to `u1`.

Qiskit's position has always been that we interpret `rz` as using the
phase convention of `RZGate`, and `u1` uses the different convention of
`PhaseGate`.  This commit adds documentation to the pages on OpenQASM 2
about this difference, and includes an example of how to override
Qiskit's default if the generating code (e.g. pyZX) wants to use an
alternative phase convention.

* Comment on the number of overrides needed

Co-authored-by: Julien Gacon <gaconju@gmail.com>

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
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 changelog documentation Something is not clear or an error documentation mod: qasm2 Relating to OpenQASM 2 import or export stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants