Open Quantum Assembly Language (OpenQASM; pronounced ''open kazm'')
is a
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
designed for describing
quantum circuit
In quantum information theory, a quantum circuit is a model for quantum computation, similar to classical circuits, in which a computation is a sequence of quantum gates, measurements, initializations of qubits to known values, and possibly o ...
s and
algorithms
In mathematics and computer science, an algorithm () is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for per ...
for execution on quantum computers.
Language
It is designed to be an
intermediate representation
An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good" ...
that can be used by higher-level compilers to communicate with quantum hardware, and allows for the description of a wide range of quantum operations, as well as classical feed-forward flow control based on measurement outcomes.
The language includes a mechanism for describing explicit timing of instructions, and allows for the attachment of low-level definitions to gates for tasks such as calibration.
[ OpenQASM is not intended for general-purpose classical computation, and hardware implementations of the language may not support the full range of data manipulation described in the specification. Compilers for OpenQASM are expected to support a wide range of classical operations for compile-time constants, but the support for these operations on runtime values may vary between implementations.
The language was first described in a paper published in July 2017,][ and a reference source code implementation was released as part of ]IBM
International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
's Quantum Information Software Kit (Qiskit
Qiskit (''Quantum Information Software Kit'') is an open-source, Python-based, high-performance software stack for quantum computing, originally developed by IBM Research and first released in 2017. It provides tools for creating quantum program ...
) for use with their IBM Quantum Experience
IBM Quantum Platform (previously known as IBM Quantum Experience) is an online platform allowing public and premium access to cloud-based quantum computing services provided by IBM. This includes access to a set of IBM's quantum processors, a set ...
cloud quantum computing platform. The language has similar qualities to traditional hardware description language
In computer engineering, a hardware description language (HDL) is a specialized computer language used to describe the structure and behavior of electronic circuits, usually to design application-specific integrated circuits (ASICs) and to progra ...
s such as Verilog
Verilog, standardized as IEEE 1364, is a hardware description language (HDL) used to model electronic systems. It is most commonly used in the design and verification of digital circuits, with the highest level of abstraction being at the re ...
.
OpenQASM defines its version at the head of a source file as a number, as in the declaration: OPENQASM 3;
The level of OpenQASM's original published implementations is OpenQASM 2.0. Version 3.0 of the specification is the current one and can be viewed at the OpenQASM repository on GitHub
GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
.
Examples
The following is an example of OpenQASM source code from the official library. The program adds two four-bit numbers.
/*
* quantum ripple-carry adder
* Cuccaro et al, quant-ph/0410184
*/
OPENQASM 3;
include "stdgates.inc";
gate majority a, b, c
gate unmaj a, b, c
qubit cin;
qubit a;
qubit b;
qubit cout;
bit ans;
uint a_in = 1; // a = 0001
uint b_in = 15; // b = 1111
// initialize qubits
reset cin;
reset a;
reset b;
reset cout;
// set input states
for i in : 3
// add a to b, storing result in b
majority cin b a
for i in : 2
cx a cout
for i in : -1: 0
unmaj cin b a
measure b :3-> ans :3
measure cout -> ans
See also
* Quantum programming
Quantum programming refers to the process of designing and implementing algorithms that operate on quantum systems, typically using quantum circuits composed of quantum gates, measurements, and classical control logic. These circuits are devel ...
* Q Sharp
References
External links
*
*
{{Use dmy dates, date=June 2024
Free software programmed in Python
Software using the Apache license
Programming languages
Quantum computing
Quantum programming