Computing Library › Quantum Ml
Quantum Ml

The HHL Algorithm and Linear Systems

The HHL algorithm solves linear systems on a quantum computer in time logarithmic in the matrix size, under conditions that sharply limit its practical reach.

Solving Ax = b, quantumly

The Harrow-Hassidim-Lloyd (HHL) algorithm addresses the linear system Ax = b. Instead of returning the solution vector x explicitly, it prepares a quantum state proportional to x. For a sparse, well-conditioned matrix of size N, it runs in time polynomial in log N, an exponential improvement over the linear-in-N cost of classical solvers, which is why HHL underlies many proposed machine learning speedups such as least-squares fitting and support vector machines.

How it works, at a high level

Kronos motion — reaching conditions

HHL prepares the state |b>, uses quantum phase estimation to write the eigenvalues of A into an ancilla register, performs a controlled rotation that multiplies each eigenvalue by its reciprocal, and uncomputes the phase estimation. The result is a state encoding A-inverse times b. The reciprocal step is what inverts the matrix in the eigenbasis.

The four caveats

Illustrative structure

python
# HHL as a pipeline of subroutines (conceptual, not runnable)
# 1. prepare |b>
# 2. phase_estimation(A) -> eigenvalues in ancilla
# 3. controlled_rotation(1/lambda)  # the inversion step
# 4. inverse_phase_estimation()
# result: state ~ A^{-1}|b>, readable only via measurements

Status and honest reading

HHL requires fault-tolerant depth far beyond NISQ hardware, and several downstream applications have been partly dequantized. The famous exponential speedup is real only when all four caveats are met simultaneously, a narrow regime. HHL is best understood as a foundational primitive for future fault-tolerant machines and a cautionary tale about counting loading and readout, not as a near-term machine learning tool.