In this article we will explore in detail OpenQASM, a topic of great relevance and interest today. OpenQASM is a concept that has generated great controversy and debate in various spheres, from the academic field to the field of politics and society in general. Over the years, OpenQASM has played a fundamental role in the way we perceive and understand the world around us, its implications have been profound and have given rise to a wide range of divergent opinions and perspectives. Through a comprehensive analysis, this article will seek to shed light on the complexity and relevance of OpenQASM, examining its historical roots, its current impacts and its projection into the future.
| OpenQASM | |
|---|---|
| Stable release | 3.1.0
/ May 15, 2024 |
| Implementation language | Python |
| License | Apache License 2.0 |
| Filename extensions | .qasm |
| Website | openqasm |
Open Quantum Assembly Language (OpenQASM; pronounced open kazm)[1] is a programming language designed for describing quantum circuits and algorithms for execution on quantum computers.
It is designed to be an intermediate representation 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.[1] 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.[2]
The language was first described in a paper published in July 2017,[1] and a reference source code implementation was released as part of IBM's Quantum Information Software Kit (Qiskit) for use with their IBM Quantum Experience cloud quantum computing platform.[3] The language has similar qualities to traditional hardware description languages such as Verilog.
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.[4]
The following is an example of OpenQASM source code from the official library. The program adds two four-bit numbers.[5]
/*
* quantum ripple-carry adder
* Cuccaro et al, quant-ph/0410184
*/
OPENQASM 3;
include "stdgates.inc";
gate majority a, b, c {
cx c, b;
cx c, a;
ccx a, b, c;
}
gate unmaj a, b, c {
ccx a, b, c;
cx c, a;
cx a, b;
}
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 {
if(bool(a_in)) x a;
if(bool(b_in)) x b;
}
// add a to b, storing result in b
majority cin, b, a;
for i in { majority a, b, a; }
cx a, cout;
for i in { unmaj a, b, a; }
unmaj cin, b, a;
measure b -> ans;
measure cout -> ans;