In 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 3 Tutorial, you will be learning about OpenQASM version string.
If you know about version string in OpenQASM 2, version strings in OpenQASM 3 are no different.
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 3.0
. The major version number in this example is 3 and the minor version number is 0.
OPENQASM 3.0
If the minor version number is not specified, then the minor version number is defaulted to 0.
Example
Below is an example of a version string that does not include the minor version number. In this example, the version string indicates the version of OpenQASM is 3.0
.
OPENQASM 3
Rules for OpenQASM 3 Version String
There are 2 rules to be kept in mind for defining version string in OpenQASM 3-
- 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 3.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.
// Initialize a Quantum Register of 2 Qubits
qubit[2] qubits;
// This is not a valid way of specifying version string
OPENQASM 3.0