OpenQASM Version String

OpenQASM Version String is used for declaring the version of OpenQASM that is to be used for reading and executing a particular OpenQASM file. In this chapter of the OpenQASM Tutorial, you will be learning about OpenQASM version string.

What is OpenQASM Version String

OpenQASM version string is used for declaring the version of OpenQASM according to which a file is written. This information is useful when reading and executing a particular OpenQASM file.

The version of an OpenQASM file is written is the form of V.v, where V is the major version number and v is the minor version number.

Example

Below is an example of a version string that indicates the version of OpenQASM is 2.0. The major version number in this example is 2 and the minor version number is 0.

OPENQASM 2.0

Rules for Version String

There are 2 rules to be kept in mind for defining version strings in OpenQASM-

  • There has to be only one occurrence of version string in a file.
  • It has to be declared in the first non-comment line of the file.

Example

Below is an example in which there are multiple occurrences of version string in the file. This is not allowed because there has to be only one occurrence of version string in the file.

OPENQASM 2.0
OPENQASM 3.0

Example

Below is an example in which the version string is the first non-comment line in the file. This is a valid way of specifying version string.

// This is a valid way of specifying version string
OPENQASM 2.0

Example

Below is an example in which the version string is not the first non-comment line in the file. This is not a valid way of specifying version string.

// Declare a Quantum Register of 4 Qubits
qreg qubits[4];

// This is not a valid way of specifying version string
OPENQASM 2.0