Jump to content

OpenQASM: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 3 templates: hyphenate params (1×);
No edit summary
Line 1: Line 1:
{{primary sources|date=September 2018}}
{{primary sources|date=September 2018}}
'''Open Quantum Assembly Language''' ('''OpenQASM'''; pronounced ''open kazm''<ref name=Cross>{{cite arxiv|title=Open Quantum Assembly Language|first1=Andrew W.|last1=Cross|first2=Lev S.|last2=Bishop|first3=John A.|last3=Smolin|first4=Jay M.|last4=Gambetta|arxiv=1707.03429}}</ref>) is an [[intermediate representation]] for quantum instructions. The language was first described in a paper published in July 2017,<ref name=Cross/> and a reference source code implementation was released as part of [[IBM]]'s Quantum Information Software Kit ([[Qiskit]]) for use with their [[IBM Q Experience]] cloud quantum computing platform.<ref>{{Citation|title=qiskit-openqasm: OpenQASM specification|date=2017-07-04|url=https://github.com/IBM/qiskit-openqasm|publisher=International Business Machines|access-date=2017-07-06}}</ref> The language has similar qualities to traditional [[hardware description language]]s such as [[Verilog]].
'''Open Quantum Assembly Language''' ('''OpenQASM'''; pronounced ''open kazm''<ref name=Cross>{{cite arxiv|title=Open Quantum Assembly Language|first1=Andrew W.|last1=Cross|first2=Lev S.|last2=Bishop|first3=John A.|last3=Smolin|first4=Jay M.|last4=Gambetta|arxiv=1707.03429}}</ref>) is an [[intermediate representation]] for quantum instructions. The language was first described in a paper published in July 2017,<ref name=Cross/> 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.<ref>{{Citation|title=qiskit-openqasm: OpenQASM specification|date=2017-07-04|url=https://github.com/IBM/qiskit-openqasm|publisher=International Business Machines|access-date=2017-07-06}}</ref> The language has similar qualities to traditional [[hardware description language]]s such as [[Verilog]].


OpenQASM defines its version at the head of a source file as a real number, as in the declaration: <syntaxhighlight lang="verilog">OPENQASM 2.0;</syntaxhighlight>
OpenQASM defines its version at the head of a source file as a real number, as in the declaration: <syntaxhighlight lang="verilog">OPENQASM 2.0;</syntaxhighlight>

Revision as of 01:51, 3 April 2021

Open Quantum Assembly Language (OpenQASM; pronounced open kazm[1]) is an intermediate representation for quantum instructions. 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.[2] 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 real number, as in the declaration:

OPENQASM 2.0;

The level of OpenQASM's original published implementations (e.g., Qiskit, infra) is OpenQASM 2.0. The 3.0 level of the specification is currently work in progress and can be viewed at the OpenQASM repository on GitHub.

Examples

The following is an example of OpenQASM source code from the official library. The program adds two four-bit numbers.[3]

// quantum ripple-carry adder from Cuccaro et al, quant-ph/0410184
OPENQASM 2.0;
include "qelib1.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; 
}
qreg cin[1];
qreg a[4];
qreg b[4];
qreg cout[1];
creg ans[5];
// set input states
x a[0]; // a = 0001
x b;    // b = 1111
// add a to b, storing result in b
majority cin[0],b[0],a[0];
majority a[0],b[1],a[1];
majority a[1],b[2],a[2];
majority a[2],b[3],a[3];
cx a[3],cout[0];
unmaj a[2],b[3],a[3];
unmaj a[1],b[2],a[2];
unmaj a[0],b[1],a[1];
unmaj cin[0],b[0],a[0];
measure b[0] -> ans[0];
measure b[1] -> ans[1];
measure b[2] -> ans[2];
measure b[3] -> ans[3];
measure cout[0] -> ans[4];

References

  1. ^ a b Cross, Andrew W.; Bishop, Lev S.; Smolin, John A.; Gambetta, Jay M. "Open Quantum Assembly Language". arXiv:1707.03429.
  2. ^ qiskit-openqasm: OpenQASM specification, International Business Machines, 2017-07-04, retrieved 2017-07-06
  3. ^ "openqasm/adder.qasm at master · QISKit/openqasm · GitHub".