Beginner

Quantum Computing Basics

Understanding qubits, quantum gates, and measurement is essential before building quantum ML models. This lesson covers the fundamentals you need.

Qubits: The Quantum Bit

A classical bit is either 0 or 1. A qubit can be in a superposition of both states simultaneously, represented as: |ψ⟩ = α|0⟩ + β|1⟩, where α and β are complex probability amplitudes satisfying |α|² + |β|² = 1.

When measured, a qubit collapses to |0⟩ with probability |α|² or |1⟩ with probability |β|². This probabilistic nature is what gives quantum computing its unique power.

Key Quantum Phenomena

PhenomenonDescriptionML Relevance
SuperpositionA qubit exists in multiple states at onceEnables parallel evaluation of many inputs
EntanglementQubits become correlated; measuring one affects the otherCreates complex feature correlations
InterferenceQuantum amplitudes can add or cancelAmplifies correct solutions, cancels wrong ones

Quantum Gates

Quantum gates are unitary operations that transform qubit states. Think of them as the quantum equivalent of classical logic gates.

  • Pauli-X (NOT gate): Flips |0⟩ to |1⟩ and vice versa. The quantum bit-flip.
  • Hadamard (H): Creates equal superposition. Maps |0⟩ to (|0⟩ + |1⟩)/√2. Essential for QML.
  • CNOT: Controlled-NOT. Entangles two qubits. If control qubit is |1⟩, flips the target.
  • Rotation Gates (RX, RY, RZ): Parameterized rotations around X, Y, Z axes. These are the trainable parameters in QML.
  • Phase Gate (S, T): Adds a phase to the |1⟩ component. Used for interference patterns.

Quantum Circuits

A quantum circuit is a sequence of quantum gates applied to qubits, followed by measurement. This is the quantum equivalent of a computational graph:

  1. Initialize Qubits

    Start with qubits in the |0⟩ state (or encode your data into qubit states).

  2. Apply Gates

    Apply a sequence of single-qubit and multi-qubit gates to transform the quantum state.

  3. Measure

    Measure the qubits to collapse them into classical bit values. Repeat many times to estimate probabilities.

The Bloch Sphere

A single qubit state can be visualized on a Bloch sphere — a unit sphere where the north pole is |0⟩ and the south pole is |1⟩. Rotation gates (RX, RY, RZ) rotate the state vector around the corresponding axis. This geometric picture is essential for understanding parameterized quantum circuits in QML.

Multiple Qubits and Entanglement

With n qubits, the quantum state lives in a 2^n-dimensional Hilbert space. For example, 2 qubits span: |00⟩, |01⟩, |10⟩, |11⟩. When qubits are entangled, their joint state cannot be described as a product of individual qubit states. This exponential state space is the source of potential quantum advantage for ML.

Key takeaway: Qubits in superposition explore exponentially many states simultaneously. Quantum gates manipulate these states, and parameterized rotation gates (RX, RY, RZ) serve as the trainable weights in quantum ML models. Entanglement creates correlations that have no classical equivalent.