Skip to main content
Introducing The Quantum Infrastructure Cloud Learn more
Back to Course
lab

Qubits and measurement

25 min

Quantum circuit

A qubit

A classical bit is 0 or 1. A qubit has a state written α|0⟩ + β|1⟩, where α and β are complex amplitudes with |α|² + |β|² = 1. Measuring it gives 0 with probability |α|² and 1 with probability |β|², and afterwards the qubit is in the state that was read.

Rotations

The gate ry(θ) rotates |0⟩ into cos(θ/2)|0⟩ + sin(θ/2)|1⟩. With θ = π/3 the amplitude of |1⟩ is sin(π/6) = 1/2, so the qubit reads 1 with probability 1/4. With θ = π/2 it reads 0 and 1 equally often, and with θ = π it always reads 1.

Shots

One measurement gives one bit. To see a probability you run the same program many times, each run a shot, and count. With 1,000 shots and a probability of 0.25 you expect about 250 ones; the count typically lands within about 14 of that (the standard deviation, √(1000 × 0.25 × 0.75)).

Your first HiQ program

HiQ Assembly names the program, declares qubits and bits, applies gates one per line and measures with measure q -> m. The lab below is the rotation above: two lines of work. Our run of 1,000 shots read 1 on 24.1% of them, within the expected spread of 25%.

HiQ lab 1

One rotation, one measurement

Rotate one qubit by ry(pi / 3) and measure it. The program has one qubit, one bit and two lines of work.

rotation.qcosHiQ Assembly
// One qubit, one rotation: ry(pi / 3) leaves |0> with amplitude cos(pi / 6)// and |1> with amplitude sin(pi / 6), so the bit reads 1 with probability 0.25.program rotationqubits qbits m​ry(pi / 3) qmeasure q -> m
What you should see
The bit reads 1 on about a quarter of the shots: sin²(pi / 6) = 0.25. With 1,000 shots, expect roughly 250 ones, give or take about 14.
What we measured
0 on 75.9% of the shots, 1 on 24.1%. QCOS checked this program and ran it on a Softquantus Cloud simulator, 1,000 shots, 13 November 2026.

Check it yourself

Save the program as rotation.qcos, set QCOS_API_KEY to a key from your workspace on the Softquantus Research Platform, and ask QCOS to check it. Change a line, check again, and see what the checker says.

pip install softqcossoftqcos lang check rotation.qcos