What’s in the latest OpenQASM specification? | by Qiskit | Qiskit | Medium
By Blake Johnson, IBM Quantum
The OpenQASM project reached a major milestone in May with the release of the OpenQASM 3.0 specification.
Since OpenQASM was first defined in 2017 in the landmark paper Open Quantum Assembly Language, it has become a lingua franca for describing quantum circuits at the lowest level. Multiple research and vendor projects support and employ OpenQASM, leading in the past few years to the further development of OpenQASM, plus its being placed under an open source Technical Steering Committee (TSC).
The OpenQASM language has seen significant advances in the past few years, starting with a proposal from IBM for an updated OpenQASM, followed by formalizing community participation in on-going development under the aegis of the Technical Steering Committee. The new TSC immediately set out to address some of the shortcomings in the draft OpenQASM 3.0 spec by launching working groups to propose updates in the following areas:
- Types and Casting
- OpenPulse grammar
- Profiles and Releases
- Pragmas
Those efforts have yielded a considerable amount of change, clarification, and improvement to the language. Some of the highlights for each working group are listed below.
The types and casting WG:
- Clarified rules for implicit and explicit casts
- Added section on ‘literals’ to the spec
- Clarified OpenQASM’s scoping rules
- Added array types, including addition of ‘readonly’ and ‘mutable’ keywords
- Sorted out behavior of ‘angle’ types
- Re-asserted that arguments to ‘gate’s are of type ‘angle’
- Re-defined the parameterization of the U gate to avoid discontinuities at 0 and 2pi.
- Removed the fixed-point type
- Removed non-floating point complex types
- Made ‘const’ a type modifier rather than a type.
OpenPulse WG:
- Proposed a complete openpulse grammar
- Created a reference parser
- Removed ‘$’ from qubit wildcards in ‘defcal’
Pragmas WG:
- Clarified how pragmas work with examples, including promoting ‘pragma’ to a keyword
Profiles and Releases WG
- Introduced semantic versioning for OpenQASM and defined release process
This last item is the motivation for this post, because last month we cut the first official OpenQASM 3.0 release. From here on, OpenQASM is adopting semantic versioning, so changes will be associated with a new major or minor version number (i.e. the next release should be 3.1). Adopting a versioning policy is critical for software tools targeted at supporting OpenQASM to be able to successfully exchange OpenQASM source files.
The OpenQASM repository on Github hosts the source of the OpenQASM Live Specification. Additionally, you will find in that repository a reference AST for OpenQASM 3 and the Python source for an ANTLR-based reference parser installable from the Python Package Index PyPi (“pip install”) as openqasm3.
Additionally, OpenQASM 3 is currently experimentally supported by Qiskit, IBM Quantum, Amazon Bracket, and Quantum Machines.
There are plenty of open questions and further directions to explore. But now there is an official OpenQASM 3 version that won’t change. So, if you have been waiting on the sidelines for OpenQASM to settle down before taking the plunge and using it in your project, wait no longer!
- Giscus
Last update: 2023-9-10