Quantum Computing
Quantum Circuits
2019. Google announces quantum supremacy: their Sycamore processor solved a specific sampling problem in 200 seconds that would take a classical supercomputer an estimated 10,000 years. The key was a carefully engineered quantum circuit of 53 qubits and 1,113 gates. Today IBM has over 20 quantum processors accessible in the cloud, and quantum circuits are running real chemistry simulations that classical computers cannot match.
- **IBM Quantum**: 20+ quantum processors available in the cloud. Algorithms written as circuits via Qiskit run on real hardware
- **VQE (Variational Quantum Eigensolver)**: hybrid algorithm for quantum chemistry - simulates molecules for drug discovery and materials design
- **QAOA (Quantum Approximate Optimization Algorithm)**: quantum circuits for combinatorial optimization - routing, scheduling, portfolio optimization
Historical context
In 1994, Peter Shor at Bell Labs published an algorithm for factoring large integers in polynomial time on a quantum computer - versus exponential time classically. This meant theoretical cryptographic break of RSA encryption. Shor's algorithm uses the Quantum Fourier Transform (QFT) - a quantum circuit computing DFT in O(n²) gates instead of O(2ⁿ) classical operations. The paper triggered a wave of government and private investment in quantum computing that persists today. In 2016, IBM made the first quantum processor publicly accessible, and in 2019 Google demonstrated quantum supremacy. The race to build fault-tolerant quantum hardware capable of running Shor's algorithm at scale continues.
Circuit model: gates as operations on qubits
IBM, 2016. IBM Q Experience became the first publicly accessible quantum processor in the cloud. The immediate question from users: how do programs work on a machine with no if-else, no variables, no loops? The answer: a quantum circuit - a sequence of gates applied to qubits in a defined order. A **quantum gate** is a unitary matrix U (U†U = I) acting on one or more qubits. Unlike classical logic gates, all quantum gates are reversible.
**Core single-qubit gates**: X (NOT - flips |0> to |1>), H (Hadamard - creates superposition), Z (phase flip), S, T. **Two-qubit gates**: CNOT, CZ, SWAP. The CNOT gate flips the target qubit if and only if the control qubit is |1> - the quantum equivalent of conditional logic.
| Gate | Matrix | Action on |0> | Action on |1> |
|---|---|---|---|
| X (NOT) | [[0,1],[1,0]] | |1> | |0> |
| H (Hadamard) | [[1,1],[1,-1]]/√2 | (|0>+|1>)/√2 | (|0>-|1>)/√2 |
| Z | [[1,0],[0,-1]] | |0> | -|1> |
| CNOT | 4x4 matrix | flip target if control=|1> | - |
Gate X is applied to state |0>. Then H is applied to the result. What is the final state?
Measurement: collapsing superposition
Measurement is the most unusual operation in quantum mechanics. A qubit in state α|0> + β|1> collapses to |0> with probability |α|² or to |1> with probability |β|² upon measurement. After measurement the superposition is destroyed - the qubit is now a classical bit. This is irreversible. A quantum algorithm is designed so that the correct answer has probability close to 1 by the time measurement occurs.
**No-Cloning Theorem:** it is impossible to copy an arbitrary quantum state. There is no way to back up a qubit before measurement. This follows from unitarity: if CNOT could copy states, it would enable quantum broadcast - a contradiction with information theory. This is a fundamental physical constraint, not a hardware limitation.
A qubit is in state (3/5)|0> + (4/5)|1>. What is the probability of measuring |1>?
Classical and quantum control
Real quantum algorithms combine quantum computation with classical processing. The pattern: state preparation (quantum) - computation - measurement - classical post-processing - possibly a new quantum step. This hybrid quantum-classical approach is the standard for NISQ (Noisy Intermediate-Scale Quantum) devices of the 2020s. The classical computer handles optimization; the quantum computer evaluates the objective function.
**Classically controlled gates:** after measuring one qubit, the classical result (0 or 1) controls an operation on another qubit. This is a key element of quantum teleportation and error correction. In Qiskit: `qc.x(1).c_if(classical_register, 1)` - apply X if measurement gave 1.
In a hybrid VQE algorithm, the quantum computer runs thousands of times. What does the classical computer do between runs?
Circuit depth and decoherence
**Circuit depth** is the critical hardware constraint for real quantum computers. Qubits lose their quantum properties (decoherence) after time T2 - typically 100-1000 microseconds for superconducting qubits. Each gate takes 10-100 nanoseconds. This means the maximum circuit depth before errors accumulate is a few hundred to a few thousand gates. Deeper circuits require error correction, which itself demands thousands of physical qubits per logical qubit.
| Architecture | T2 (coherence time) | Gate time | Max practical depth |
|---|---|---|---|
| Superconductors (IBM, Google) | 100-1000 µs | 10-50 ns | ~1000 |
| Trapped ions (IonQ, Quantinuum) | seconds - minutes | 1-10 µs | ~10,000 |
| Photonics | very long (photons) | picoseconds | limited by losses |
| Neutral atoms | seconds | 1-10 µs | ~10,000 |
A quantum computer tries all possibilities in parallel and instantly finds the answer
A quantum computer creates superposition, applies interference to amplify the correct answer, measures, and gets one random outcome. The algorithm runs thousands of times.
Measurement collapses superposition to one value. Quantum speedup comes from constructive interference (correct answers amplified) and destructive interference (wrong answers suppressed). Without a clever algorithm, a quantum computer is no better than a coin flip.
A circuit with depth 500 runs on a superconducting quantum computer with T2=200 µs and gate time=50 ns. Will the result be correct?
Key ideas
- A quantum circuit is a sequence of unitary gates (X, H, CNOT, etc.) on qubits, terminated by measurement
- Measurement collapses superposition α|0>+β|1> to |0> with probability |α|² or |1> with probability |β|²
- Circuit depth is limited by coherence time T2 - each gate adds ~50 ns on superconductors
- Hybrid algorithms (VQE, QAOA) alternate quantum computation with classical optimization
- No-cloning: an arbitrary quantum state cannot be copied - fundamental physics, not engineering limitation
Вопросы для размышления
- Grover's search algorithm achieves a sqrt(N) speedup over classical search. If the algorithm runs once, does it guarantee finding the correct element? What circuit modification increases success probability?
- IBM superconducting qubits have T2 ~200 µs. Trapped ion qubits have T2 of seconds but slower gates. For what categories of algorithms does each architecture have an advantage?
- Quantum error correction requires thousands of physical qubits per logical qubit. How does this change the required hardware scale for running Shor's algorithm on RSA-2048?
Связанные уроки
- qc-03 — Qubits, superposition, and entanglement - the basic elements that circuits operate on
- qc-05 — Grover's search algorithm is built from the single-qubit and multi-qubit gates covered here
- qc-06 — Shor's algorithm - the most consequential quantum circuit - uses QFT as a subroutine
- dsp-04 — Quantum Fourier Transform is the quantum analog of DFT, achieving exponential speedup for specific problem structures
- se-04 — Decomposing complex quantum operations into elementary gates mirrors the SRP: each gate does one simple unitary transformation
- la-01-vectors-intro