QASM: Qubit initialization and measurement

Qubit initialization

By default, qubits will be initialized in the ground state in the z-basis at the start of the algorithm. Initialization in this state can be done specifically using the prep_z instruction. Initialization can also be done along other bases. cQASM defines three prepare statements:

Depending on the hardware backend, preparation in a basis other than the z-basis may actually expand to an initialization in the z-basis followed by a rotation to obtain one of the basis states in the desired base.

Qubit measurement

Each qubit in the qubit register has a corresponding classical bit in a classical register, known as the binary register. The mapping is simple: the qubit with index 0 has a corresponding classical bit with index 0. Qubit 1 corresponds to bit 1. In general, the qubit at index nn corresponds to the classical bit with index nn.

The result of a measurement on a single qubit is 0 or 1. The measurement instructions store the result of measuring a qubit in the corresponding classical bit register.

As an example, let’s look at this simple cQASM program:

          version 1.0
qubits 2
prep_z q[0]
X q[0]
measure_z q[0]

The measurement taken at line 5 will measure the qubit at index 0 in the z-basis, and store the result (a classical 0 or 1) in the classical register at index 0.

The most used measurement is in the z-basis, which can be expressed in cQASM as measure_z or just measure. The full list of measurement instructions is:

Note that only one binary register is used. When a qubit is measured multiple times during an algorithm, the corresponding bit in the binary register will be overwritten by the new measurement result, even when a measurement is done in a basis different than the basis used for an earlier measurement. Measurement results of qubit q[n] will always be stored in binary register b[n].