|q⟩ Bad Qubits

intermediate · Programming · Quantum Machine Learning (Intro)

Quantum Feature Maps

Classical machine learning often succeeds by lifting data into a richer representation where patterns become linearly separable. The same idea drives quantum feature maps: a parameterised quantum circuit ϕ(x)\phi(\mathbf{x}) embeds a data point xRd\mathbf{x} \in \mathbb{R}^d into a quantum state ϕ(x)|\phi(\mathbf{x})\rangle inside a Hilbert space whose dimension grows exponentially with the number of qubits. The inner product between two such states defines a quantum kernel

K(x,x)=ϕ(x)ϕ(x)2,K(\mathbf{x}, \mathbf{x}') = |\langle \phi(\mathbf{x}') | \phi(\mathbf{x}) \rangle|^2,

which a classical support-vector machine can use without ever writing down the full feature vector.

Why Hilbert space is large

An nn-qubit state lives in a 2n2^n-dimensional complex vector space. Even for n=10n = 10 that is 10241024 dimensions. Encoding a single real number per qubit already creates a 10241024-dimensional feature map from a ten-dimensional input — a compression ratio impossible to replicate classically without specialised structure.

Angle encoding

The simplest quantum feature map rotates each qubit by one data coordinate. For a single feature x[π,π]x \in [-\pi, \pi], an RyR_y rotation encodes xx as

ϕ(x)=Ry(x)0=cos ⁣x20+sin ⁣x21.|\phi(x)\rangle = R_y(x)|0\rangle = \cos\!\tfrac{x}{2}|0\rangle + \sin\!\tfrac{x}{2}|1\rangle.

For a dd-dimensional input x=(x0,x1,,xd1)\mathbf{x} = (x_0, x_1, \ldots, x_{d-1}) applied qubit-by-qubit, the product state is

ϕ(x)=j=0d1Ry(xj)0.|\phi(\mathbf{x})\rangle = \bigotimes_{j=0}^{d-1} R_y(x_j)|0\rangle.

This is a separable (unentangled) embedding. The kernel it induces is

K(x,x)=j=0d1cos2 ⁣xjxj2,K(\mathbf{x}, \mathbf{x}') = \prod_{j=0}^{d-1} \cos^2\!\tfrac{x_j - x'_j}{2},

which is a product of squared cosine similarities — a well-known classical kernel. Angle encoding alone therefore gives no quantum advantage; we need entanglement to create cross-feature correlations that classical kernels cannot reproduce cheaply.

The ZZ feature map

Havlicek et al. (2019) introduced the ZZ feature map, which adds entangling layers between the rotation layers. For two qubits and features (x0,x1)(x_0, x_1), one layer of the ZZ map is:

  1. Apply HH to every qubit to create an equal superposition.
  2. Apply P(2xj)P(2 x_j) (a ZZ-axis phase rotation by 2xj2x_j) to each qubit jj.
  3. Apply CNOT01CNOT_{01} followed by P(2(πx0)(πx1))P(2(\pi - x_0)(\pi - x_1)) on qubit 1, then CNOT01CNOT_{01} again. This two-qubit term encodes cross-products of the features.

The entangling step creates amplitudes that depend on products of features, which effectively gives access to polynomial and interaction features without enumerating them explicitly. The quantum kernel then lives in a space spanned by states like 00|00\rangle, 01|01\rangle, 10|10\rangle, 11|11\rangle weighted by trigonometric polynomials in the products xixjx_i x_j.

Expressibility and trainability

Not every feature map is useful. Two important properties guide the choice:

Expressibility measures how well the set of states {ϕ(x)}\{|\phi(\mathbf{x})\rangle\} covers the Hilbert space. A highly expressible map can represent complex decision boundaries, but also risks being unstructured enough that the kernel loses any inductive bias useful for the task.

Trainability (in the variational setting where the encoding includes learnable parameters θ\boldsymbol{\theta}) is limited by the barren plateau phenomenon: as nn grows, the gradient of an expressible circuit concentrates exponentially close to zero, making gradient-based optimisation hard.

These two concerns pull in opposite directions, which is why quantum machine learning practitioners carefully design shallow, structured feature maps rather than simply maximising expressibility.

Summary

| Property | Angle encoding | ZZ feature map | |---|---|---| | Entanglement | None | Yes (CNOT layers) | | Classical kernel match | Yes (cosine product) | Conjectured hard to simulate | | Feature interactions | None | Pairwise and higher | | Depth for nn qubits | O(n)O(n) | O(n2)O(n^2) per layer |

Quantum feature maps are the bridge between raw data and quantum computation. Choosing the right map is as important as choosing the right architecture in classical deep learning — and it is still an open problem to know when a quantum kernel will truly outperform its classical counterparts.

Sign in on the full site to ask questions and join the discussion.