Learning path: from one qubit to algorithms
A course-shaped route through QubitLab, organised the way IBM Quantum Learning organises its courses: single systems → multiple systems → circuits → entanglement in action → query algorithms → phase estimation. Each lesson ends with an exercise that opens in the IDE; use Compile to see the state and Debug (F5) to watch it form gate by gate.
How to study: read the lesson, open the exercise, predict the probabilities before you press Compile, then check. Write your prediction down first; the surprise is where the learning is.
Module 1 · Single systems
A classical bit is 0 or 1. A probabilistic bit is a vector of probabilities (p₀, p₁) that sum to 1. A qubit is a vector of amplitudes (α, β) whose squared magnitudes sum to 1, and amplitudes can be negative or complex. That one change, from probabilities to amplitudes, is where interference comes from.
- Operations are unitary matrices; measurement is the only non-reversible step.
- H turns |0⟩ into (|0⟩+|1⟩)/√2; applying H twice gives |0⟩ back, which a coin flip could never do.
- Global phase is invisible; relative phase is everything (watch the Q-sphere colours).
Interference in one line
Predict the outcome of H · Z · H on |0⟩, then run it. Compare with H · H.
OPENQASM 3.0; include "stdgates.inc"; qubit[1] q; bit[1] c; h q[0]; z q[0]; h q[0]; c[0] = measure q[0];
Hint
Z flips the sign of the |1⟩ amplitude between the two Hadamards. Step through it in Debug mode and watch the Amplitudes view.
Check your answer
|1⟩ with probability 100 %: HZH = X. Without the Z you get |0⟩ with 100 %. The middle state is identical in probabilities (50/50) for both circuits; only the phase differs.
Module 2 · Multiple systems
Two qubits are described by four amplitudes, |00⟩, |01⟩, |10⟩, |11⟩ (Qiskit writes qubit 0 as the rightmost bit). A product state is one you can factor as |a⟩⊗|b⟩. States that cannot be factored are entangled, and those are the ones a two-qubit gate like CNOT creates.
Product or entangled?
Two circuits, same probabilities? Run H on both qubits (product state) and compare with H then CNOT (Bell state). Look at the Bloch view in Debug mode.
OPENQASM 3.0; include "stdgates.inc"; qubit[2] q; bit[2] c; h q[0]; h q[1]; c = measure q;
Hint
In a product state each Bloch arrow has length 1. In an entangled state the arrows shrink to the centre (purity 0.5).
Check your answer
H⊗H gives all four outcomes at 25 % with both arrows pointing along +X. The Bell circuit gives only 00 and 11 at 50 % and both arrows vanish: the qubits are tagged entangled.
Module 3 · Quantum circuits
A circuit is a product of unitaries read left to right in the drawing but applied right to left in the math: U = U₃U₂U₁. Inner products ⟨φ|ψ⟩ measure overlap; projections |x⟩⟨x| describe measurement. Two limits worth knowing: you cannot copy an unknown state (no-cloning) and you cannot read amplitudes directly, only sample outcomes.
Order matters
Does X then H equal H then X? Run both on |0⟩ and compare the Amplitudes view, not only the probabilities.
OPENQASM 3.0; include "stdgates.inc"; qubit[1] q; bit[1] c; x q[0]; h q[0]; c[0] = measure q[0];
Hint
Both give 50/50. Look at the sign of the |1⟩ amplitude.
Check your answer
X·H|0⟩ = (|0⟩−|1⟩)/√2 while H·X|0⟩ = (|0⟩+|1⟩)/√2 up to global phase: same probabilities, opposite relative phase. A later H would send them to |1⟩ and |0⟩ respectively.
Module 4 · Entanglement in action
Three protocols show what a shared Bell pair buys you. Teleportation moves an unknown qubit state using one Bell pair and two classical bits. Superdense coding sends two classical bits with one qubit. The CHSH game wins 85 % of the time with entanglement against a 75 % classical ceiling. QubitLab's debugger needs measurements at the end, so the circuits below use the deferred-measurement form: the classical corrections become CX and CZ gates controlled by the qubits that would have been measured.
Teleportation (deferred measurement)
q0 holds the state to send (prepared with ry(0.8)). After the circuit, q2 should carry that same state. Debug it and compare the Bloch arrow of q0 at step 1 with the arrow of q2 at the end.
OPENQASM 3.0; include "stdgates.inc"; qubit[3] q; bit[1] c; ry(0.8) q[0]; h q[1]; cx q[1], q[2]; cx q[0], q[1]; h q[0]; cx q[1], q[2]; cz q[0], q[2]; c[0] = measure q[2];
Hint
Steps 2–3 make the Bell pair; 4–5 are the Bell measurement basis change; 6–7 apply the corrections.
Check your answer
q2 ends with Bloch vector (sin 0.8, 0, cos 0.8) ≈ (0.72, 0, 0.70), the same as q0 had after ry(0.8). q0 and q1 end up maximally mixed: the original is gone, as no-cloning demands. Measuring q2 gives |1⟩ with probability sin²(0.4) ≈ 15.2 %.
Superdense coding
Alice and Bob share a Bell pair. Alice encodes two bits on her qubit (q0) with X and/or Z, sends it, and Bob decodes with CX then H. Change the encoding gates and predict the two measured bits.
OPENQASM 3.0; include "stdgates.inc"; qubit[2] q; bit[2] c; h q[0]; cx q[0], q[1]; // Alice encodes 11: apply both z q[0]; x q[0]; // Bob decodes cx q[0], q[1]; h q[0]; c = measure q;
Hint
No gate → 00. X alone → bitstring 10 (c[1]=1). Z alone → 01 (c[0]=1). Z then X → 11.
Check your answer
With Z and X the result is |11⟩ with 100 %: one qubit carried two classical bits because the Bell pair was shared in advance.
CHSH: the 85 % strategy
Alice measures q0 in the Z basis (a = 0), Bob measures q1 rotated by −π/8 (b = 0). Run with 4096 shots and compute P(same answer). Then try ry(3π/8) for Bob's other setting.
OPENQASM 3.0; include "stdgates.inc"; qubit[2] q; bit[2] c; h q[0]; cx q[0], q[1]; ry(-pi/4) q[1]; c = measure q;
Hint
ry(θ) before a Z measurement is the same as measuring along a Bloch-sphere axis tilted by θ in the X–Z plane; P(same) = cos²(θ/2).
Check your answer
P(00) + P(11) = cos²(π/8) ≈ 85.4 %. The same number appears for the other three setting pairs (with one flipped), which beats the classical bound of 75 %.
Module 5 · Query algorithms
In the query model you are given a black-box function f and count how many times you must call it. Deutsch's problem (is a 1-bit f constant or balanced?) takes one quantum query instead of two. Deutsch–Jozsa scales this to n bits with one query against 2ⁿ⁻¹+1 classically. Grover finds a marked item among N with about √N queries. The example gallery has Deutsch–Jozsa and a 2-qubit Grover; both are small enough to debug.
Deutsch's algorithm
The oracle below implements f(x) = x (balanced) as a CNOT. Run it: q0 = 1 means balanced, q0 = 0 means constant. Replace the CNOT by nothing (f = 0) or by an X on q1 (f = 1) and check that q0 becomes 0.
OPENQASM 3.0; include "stdgates.inc"; qubit[2] q; bit[1] c; x q[1]; h q[0]; h q[1]; // oracle for f(x) = x cx q[0], q[1]; h q[0]; c[0] = measure q[0];
Hint
q1 is prepared in |−⟩ so the oracle kicks the phase (−1)^f(x) back onto q0. The final H turns that phase pattern into a 0 or 1.
Check your answer
With the CNOT, c[0] = 1 with probability 100 % (balanced). With no oracle or an X on q1 alone, c[0] = 0 with 100 % (constant). One query decides, classically you need two.
Module 6 · Phase estimation and the QFT
Phase estimation reads out the eigenphase θ of a unitary, U|ψ⟩ = e^{2πiθ}|ψ⟩, by controlled powers of U followed by an inverse quantum Fourier transform. It is the engine inside Shor's algorithm and quantum chemistry. The 3-qubit QFT example in the gallery shows the controlled-phase ladder; the exercise below estimates a phase of exactly 1/4 with two counting qubits.
Estimate a phase of 1/4
U = S has eigenphase 1/4 on |1⟩ (S|1⟩ = i|1⟩ = e^{2πi/4}|1⟩). With two counting qubits the answer should read 01 in binary, i.e. 1/4. Run it and read c[1]c[0].
OPENQASM 3.0; include "stdgates.inc"; qubit[3] q; bit[2] c; // eigenstate |1> on q2 x q[2]; h q[0]; h q[1]; // controlled-U^1 and controlled-U^2 (S and S^2 = Z) cp(pi/2) q[0], q[2]; cp(pi) q[1], q[2]; // inverse QFT on q0,q1 swap q[0], q[1]; h q[0]; cp(-pi/2) q[0], q[1]; h q[1]; c[0] = measure q[0]; c[1] = measure q[1];
Hint
cp(λ) controlled on |1⟩ of q2 is the same as controlled-S for λ = π/2 and controlled-Z for λ = π.
Check your answer
The counting register reads 01 with probability 100 %: 1/2² = 0.25. Change S to T (cp(pi/4), cp(pi/2)) and the phase 1/8 is no longer exact with two qubits, so several outcomes appear.
Module 7 · Quantum computing in practice
- Running circuits: Compile shows the transpiled circuit for a target; Submit runs it on an ideal simulator, a noisy fake backend or real IBM hardware (your token, ≤ 6 qubits).
- Noise: Debug mode with a fake backend shows fidelity falling gate by gate; the Metrics tab gives TVD and Hellinger fidelity between ideal and noisy distributions.
- Mapping: Compare levels shows how optimisation level changes depth and SWAP count on a real coupling map.
- Too big for the device: circuit cutting estimates the sampling overhead and reconstructs expectation values from sub-circuits.
Go further
These lessons follow the shape of IBM Quantum Learning's courses so that you can continue there with the same vocabulary. The PennyLane codebook covers the same ground with code exercises; the next chapter borrows its style for quantum machine learning.
- IBM · Basics of quantum information Single systems, multiple systems, circuits, entanglement in action; ends with an exam and badge.
- IBM · Fundamentals of quantum algorithms Query algorithms, algorithmic foundations, phase estimation and factoring, Grover.
- IBM · Quantum computing in practice Running circuits, utility-scale QAOA, mapping problems, simulating nature.
- PennyLane codebook Theory plus hands-on codercises: single-qubit gates, many qubits, algorithms, QFT, QPE, Shor, variational algorithms.