Quantum Primer
A practical introduction to quantum computing concepts, focused on what you need to know to solve challenges. No prior quantum experience required.
Chapters
Qubits and States
Classical Bits vs Qubits
A classical bit is either 0 or 1. A qubit (quantum bit) can also be 0 or 1, but unlike a classical bit, it can exist in a superposition of both states simultaneously. This is the foundational concept behind quantum computing.
Superposition
When a qubit is in superposition, it has some probability of being measured as 0 and some probability of being measured as 1. These probabilities are described by complex numbers called amplitudes.
A qubit's state can be written as:
Where and are complex amplitudes. The probability of measuring 0 is and the probability of measuring 1 is . These probabilities always sum to 1.
Dirac Notation
Quantum states are written using Dirac notation (also called bra-ket notation). This is the standard notation used in quantum computing and you will see it throughout challenge descriptions.
The "zero" state. A qubit that will always measure as 0. This is the default initial state of qubits.
The "one" state. A qubit that will always measure as 1.
Equal superposition: . Created by applying a Hadamard gate to . 50% chance of measuring 0 or 1.
Minus superposition: . Created by applying a Hadamard gate to . Also 50/50, but with a different phase.
Multi-Qubit States
When you have multiple qubits, the state space grows exponentially. Two qubits have four possible states: , , , and . Three qubits have eight possible states, and so on. A system of qubits has basis states.
This exponential growth is the source of quantum computing's potential power. A classical computer needs numbers to describe qubits, but the qubits themselves exist in this full space naturally.
Quantum Gates
Quantum gates are operations that transform qubit states. They are the quantum equivalent of classical logic gates (AND, OR, NOT), but they work on superpositions and must be reversible (unitary).
Single-Qubit Gates
X Gate (Pauli-X)
qc.x(qubit)The quantum NOT gate. Flips to and vice versa. Often called a "bit flip."
Z Gate (Pauli-Z)
qc.z(qubit)Leaves unchanged but maps to . Introduces a "phase flip" that affects interference. Has no effect on measurement probabilities alone.
Y Gate (Pauli-Y)
qc.y(qubit)Combines the effects of X and Z (with a factor of ). Flips the state and adds a phase.
Hadamard Gate (H)
qc.h(qubit)The most important single-qubit gate. Maps to (equal superposition) and to . Applying H twice returns to the original state.
S Gate (Phase Gate)
qc.s(qubit)Adds a phase to . A "quarter turn" around the Z-axis of the Bloch sphere. .
T Gate
qc.t(qubit)Adds a phase to . A finer rotation than S. . Important for fault-tolerant quantum computing.
Rotation Gates
Rotation gates allow precise, continuous control over qubit states. They take an angle parameter and rotate the qubit around a specific axis of the Bloch sphere.
qc.rx(θ, qubit)X-axis rotation
qc.ry(θ, qubit)Y-axis rotation
qc.rz(θ, qubit)Z-axis rotation
, (up to global phase). Rotation gates generalise the Pauli gates and are essential for variational quantum circuits.
Multi-Qubit Gates
CNOT (CX)
qc.cx(control, target)The controlled-NOT gate. Flips the target qubit if and only if the control qubit is . The most common two-qubit gate. Essential for creating entanglement.
CZ
qc.cz(control, target)Controlled-Z. Applies a Z gate to the target if the control is . Symmetric: it does not matter which qubit you call control or target.
SWAP
qc.swap(qubit1, qubit2)Exchanges the states of two qubits. Equivalent to three CNOT gates. Useful when you need to rearrange qubit positions.
Toffoli (CCX)
qc.ccx(ctrl1, ctrl2, target)Double-controlled NOT. Flips the target only when both control qubits are . The quantum equivalent of a classical AND gate.
Gate matrices
Every quantum gate is represented by a unitary matrix. For single-qubit gates, this is a 2×2 matrix. For two-qubit gates, it is 4×4. You do not need to know the matrices to solve challenges, but understanding them helps conceptualise what gates do to quantum states.
Circuits and Measurement
Building Circuits
A quantum circuit is a sequence of gates applied to qubits. Gates are applied left-to-right (in the order you write them in code). All qubits start in the state unless otherwise specified.
A circuit that creates the Bell state :
qc = QuantumCircuit(2)
qc.h(0) # Hadamard on qubit 0 → creates superposition
qc.cx(0, 1) # CNOT: entangles qubit 0 and qubit 1
# Result: (|00⟩ + |11⟩)/√2Circuit Depth
Circuit depth is the number of time steps needed to execute the circuit, assuming gates on different qubits can run in parallel. It measures the critical path length, not the total gate count.
Example: Depth 2
H on qubit 0, then CNOT(0,1). Two layers of operations. The H must finish before the CNOT can use qubit 0.
Example: Depth 1
H on qubit 0 and X on qubit 1 simultaneously. These operate on different qubits, so they run in the same time step.
Measurement
Measurement collapses a qubit's superposition into a definite classical value: 0 or 1. The probability of each outcome is determined by the amplitudes of the quantum state.
Measurement is probabilistic
A qubit in the state has a 50% chance of measuring 0 and 50% chance of measuring 1. You cannot predict which outcome will occur for a single measurement.
Measurement is destructive
After measurement, the superposition is destroyed. The qubit collapses to whichever state was observed. You cannot "un-measure" a qubit.
Statistical results
By running a circuit many times (shots), you build up a probability distribution. With enough shots, the distribution converges to the true probabilities.
Platform note
On Qubit Forge, your circuits are evaluated using a statevector simulator, which computes exact probabilities without needing to run thousands of shots. You do not need to add measurement gates -- the platform handles this automatically.
Entanglement
What Entanglement Is (and Isn't)
Entanglement is a correlation between qubits that has no classical equivalent. When two qubits are entangled, measuring one instantly determines the state of the other, regardless of the distance between them.
Entanglement IS
- A quantum correlation between particles
- A resource for quantum algorithms
- Created by multi-qubit gates (CNOT, CZ)
- Measurable through correlated outcomes
Entanglement IS NOT
- Faster-than-light communication
- Cloning or copying quantum states
- A way to send information instantly
- The same as classical correlation
Bell States
The Bell states are the four maximally entangled two-qubit states. They are the simplest examples of entanglement and appear frequently in challenges.
Created by: H(0), CNOT(0,1)
Created by: H(0), Z(0), CNOT(0,1)
Created by: X(1), H(0), CNOT(0,1)
Created by: X(1), H(0), Z(0), CNOT(0,1)
Entanglement as a Resource
Entanglement is not just a curiosity -- it is a computational resource. Quantum algorithms exploit entanglement to achieve speedups over classical algorithms. Key applications include:
- Quantum teleportation: transferring quantum states using entanglement and classical communication
- Superdense coding: sending two classical bits using one qubit and shared entanglement
- Quantum error correction: protecting information by encoding it across entangled qubits
- Algorithm speedups: Grover's search and Shor's factoring both rely on entanglement
Algorithms Overview
Quantum Parallelism
A quantum computer can evaluate a function on all possible inputs simultaneously by preparing a superposition of inputs. This is not the same as classical parallelism -- you cannot directly read out all results. The art of quantum algorithms is designing circuits that extract useful information from the superposition through measurement.
Interference and Amplitude Manipulation
Quantum algorithms work by manipulating amplitudes so that correct answers have higher probability and wrong answers have lower probability. This is achieved through interference:
Constructive Interference
Amplitudes add together, increasing the probability of a particular outcome. Correct answers are amplified.
Destructive Interference
Amplitudes cancel each other out, reducing the probability of a particular outcome. Wrong answers are suppressed.
Key Algorithm Families
These algorithm families appear in Master-level challenges. Understanding the high-level idea is more important than memorising implementations.
Deutsch-Jozsa
Determines whether a function is constant or balanced using a single query. The simplest demonstration of quantum speedup. Tests your understanding of oracles and interference.
Grover's Search
Searches an unsorted database in time versus classically. Uses amplitude amplification: mark the target state, then amplify its amplitude through repeated Grover iterations.
Quantum Phase Estimation (QPE)
Estimates the eigenvalue (phase) of a unitary operator. A fundamental subroutine used in many other algorithms, including Shor's algorithm for factoring.
Variational Quantum Eigensolver (VQE)
A hybrid classical-quantum algorithm for finding ground state energies. Uses parameterised circuits with rotation gates. The classical optimiser adjusts gate angles based on measurement results.
Quantum Fourier Transform (QFT)
The quantum analogue of the discrete Fourier transform. Operates exponentially faster than its classical counterpart. Core component of phase estimation and factoring algorithms.
Practical Considerations
On Qubit Forge, you are not just solving for correctness -- you are solving for efficiency. These practical techniques help you design better circuits.
Circuit Depth Management
Parallelise independent operations
If two gates act on different qubits, they can execute in the same time step. Apply them back-to-back in your code and Qiskit will optimise the depth.
Avoid unnecessary serialisation
Only create dependencies between gates when the algorithm requires it. A Hadamard on qubit 0 and an X on qubit 1 have no dependency.
Use native multi-qubit gates
A single CNOT is depth 1. Decomposing it into multiple single-qubit operations increases depth unnecessarily.
Gate Count Optimisation
Combine rotations
Two consecutive gates on the same qubit can be combined into a single with the summed angle. Three H gates = one H gate (since ).
Choose the right gate
Use the most direct gate for the job. If you need a phase flip, use Z directly rather than .
Eliminate identity operations
Applying a gate and then its inverse accomplishes nothing. , , . Remove these redundancies.
Why Constraints Matter
Qubit Forge challenges impose constraints for a reason: on real quantum hardware, every gate introduces noise (errors) and every qubit is expensive. Efficient circuits are not just an academic exercise -- they are essential for practical quantum computing.
- Fewer gates = less accumulated noise on real hardware
- Shallower circuits = less decoherence (qubits lose their quantum properties over time)
- Fewer qubits = more practical deployability on current hardware
- Constraint awareness is a core quantum engineering skill that employers value
What's Next
This primer covers the core concepts used in Qubit Forge challenges. For deeper learning, explore the external resources on the main Resources page, or start solving challenges to apply what you have learned.