QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
  1. Docs
  2. Learning path: from one qubit to algorithms
Learn
  • Quantum basics
  • OpenQASM 3 cheat sheet
  • All gates, with the math
  • Every gate, interactive
  • Entanglement: how CNOT connects qubits
Circuits
  • Dynamic circuits: if/else, loops and conditions
Lessons
  • Learning path: from one qubit to algorithms
  • Quantum machine learning by hand
Run
  • Compile (transpile): levels, basis gates, topology
  • Simulators, noise, T1/T2 and fake backends
  • Python in the Playground
  • GitHub and git in the Playground
  • Articles and sharing
Analyze
  • Metrics: comparing distributions
  • Q-sphere and Bloch spheres
Hardware
  • Real IBM Quantum hardware
  • Device topology and calibration heat maps
  • Benchmark circuits: MQT Bench and QASMBench
Advanced
  • Circuit cutting, in depth
Story
  • The story of quantum computing
  • The Hamiltonian: where gates come from
  • What to expect next
Documentation/Lessons/Learning path: from one qubit to algorithms

Learning path: from one qubit to algorithms

A course-shaped route through QubitLab: one qubit → many qubits → circuits and their limits → what entanglement buys you → 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 · One qubit

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.

∣ψ⟩=α∣0⟩+β∣1⟩,∣α∣2+∣β∣2=1,p(0)=∣α∣2
Born rule: measuring in the computational basis gives 0 with probability |α|².
  • 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).
Exercise

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];
Open in IDE
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 · Many qubits

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.

(α∣0⟩+β∣1⟩)⊗(γ∣0⟩+δ∣1⟩)=αγ∣00⟩+αδ∣01⟩+βγ∣10⟩+βδ∣11⟩
Tensor product of two single-qubit states. The Bell state (|00⟩+|11⟩)/√2 has no such factorisation.
Exercise

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;
Open in IDE
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 · Circuits and their limits

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.

Exercise

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];
Open in IDE
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 · What entanglement buys you

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.

Exercise

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];
Open in IDE
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 %.

Exercise

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;
Open in IDE
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.

Exercise

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;
Open in IDE
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.

Exercise

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];
Open in IDE
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.

QFT∣j⟩=N​1​k=0∑N−1​e2πijk/N∣k⟩,θ≈2nmeasured integer​
With n counting qubits the measured integer divided by 2ⁿ approximates the phase.
Exercise

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];
Open in IDE
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 · On real hardware

  • 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, up to the machine's size).
  • 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 pair well with IBM Quantum Learning's courses, which use the same vocabulary, so you can continue there. The PennyLane codebook covers similar ground with code exercises; the next chapter works through quantum machine learning by hand.

  • 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 code exercises: single-qubit gates, many qubits, algorithms, QFT, QPE, Shor, variational algorithms.
← Previous
Entanglement: how CNOT connects qubits
Next →
Quantum machine learning by hand
On this page
  • Module 1 · One qubit
  • Module 2 · Many qubits
  • Module 3 · Circuits and their limits
  • Module 4 · What entanglement buys you
  • Module 5 · Query algorithms
  • Module 6 · Phase estimation and the QFT
  • Module 7 · On real hardware
  • Go further
Try it in the IDE →
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in