Back to Resources
Quantum Primer

Quantum Primer

A practical introduction to quantum computing concepts, focused on what you need to know to solve challenges. No prior quantum experience required.

1

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:

ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle

Where α\alpha and β\beta are complex amplitudes. The probability of measuring 0 is α2|\alpha|^2 and the probability of measuring 1 is β2|\beta|^2. 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.

0|0\rangle

The "zero" state. A qubit that will always measure as 0. This is the default initial state of qubits.

1|1\rangle

The "one" state. A qubit that will always measure as 1.

+|+\rangle

Equal superposition: 0+12\frac{|0\rangle + |1\rangle}{\sqrt{2}}. Created by applying a Hadamard gate to 0|0\rangle. 50% chance of measuring 0 or 1.

|-\rangle

Minus superposition: 012\frac{|0\rangle - |1\rangle}{\sqrt{2}}. Created by applying a Hadamard gate to 1|1\rangle. 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: 00|00\rangle, 01|01\rangle, 10|10\rangle, and 11|11\rangle. Three qubits have eight possible states, and so on. A system of nn qubits has 2n2^n basis states.

This exponential growth is the source of quantum computing's potential power. A classical computer needs 2n2^n numbers to describe nn qubits, but the qubits themselves exist in this full space naturally.

2

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 0|0\rangle to 1|1\rangle and vice versa. Often called a "bit flip."

Z Gate (Pauli-Z)

qc.z(qubit)

Leaves 0|0\rangle unchanged but maps 1|1\rangle to 1-|1\rangle. 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 ii). Flips the state and adds a phase.

Hadamard Gate (H)

qc.h(qubit)

The most important single-qubit gate. Maps 0|0\rangle to +|+\rangle (equal superposition) and 1|1\rangle to |-\rangle. Applying H twice returns to the original state.

S Gate (Phase Gate)

qc.s(qubit)

Adds a π2\frac{\pi}{2} phase to 1|1\rangle. A "quarter turn" around the Z-axis of the Bloch sphere. S2=ZS^2 = Z.

T Gate

qc.t(qubit)

Adds a π4\frac{\pi}{4} phase to 1|1\rangle. A finer rotation than S. T2=ST^2 = S. Important for fault-tolerant quantum computing.

Rotation Gates

Rotation gates allow precise, continuous control over qubit states. They take an angle parameter θ\theta and rotate the qubit around a specific axis of the Bloch sphere.

Rx(θ)R_x(\theta)

qc.rx(θ, qubit)

X-axis rotation

Ry(θ)R_y(\theta)

qc.ry(θ, qubit)

Y-axis rotation

Rz(θ)R_z(\theta)

qc.rz(θ, qubit)

Z-axis rotation

Rx(π)=XR_x(\pi) = X, Rz(π)=ZR_z(\pi) = Z (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 1|1\rangle. 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 1|1\rangle. 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 1|1\rangle. 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.

3

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 0|0\rangle state unless otherwise specified.

A circuit that creates the Bell state Φ+|\Phi^+\rangle:

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⟩)/√2

Circuit 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 +|+\rangle 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.

4

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.

Φ+|\Phi^+\rangle

00+112\frac{|00\rangle + |11\rangle}{\sqrt{2}}

Created by: H(0), CNOT(0,1)

Φ|\Phi^-\rangle

00112\frac{|00\rangle - |11\rangle}{\sqrt{2}}

Created by: H(0), Z(0), CNOT(0,1)

Ψ+|\Psi^+\rangle

01+102\frac{|01\rangle + |10\rangle}{\sqrt{2}}

Created by: X(1), H(0), CNOT(0,1)

Ψ|\Psi^-\rangle

01102\frac{|01\rangle - |10\rangle}{\sqrt{2}}

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
5

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 O(N)O(\sqrt{N}) time versus O(N)O(N) 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.

6

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 RzR_z gates on the same qubit can be combined into a single RzR_z with the summed angle. Three H gates = one H gate (since H2=IH^2 = I).

Choose the right gate

Use the most direct gate for the job. If you need a phase flip, use Z directly rather than Rz(π)R_z(\pi).

Eliminate identity operations

Applying a gate and then its inverse accomplishes nothing. XX=IXX = I, HH=IHH = I, CNOTCNOT=I\text{CNOT} \cdot \text{CNOT} = I. 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.