What Gets Compressed
A quantum autoencoder learns a unitary that packs the information of qubits into qubits, leaving the remaining in a fixed product state:
The error term is the whole game: the encoder is judged by how close the discarded qubits are to after the forward pass, because only then can they be traced away and the payload reassigned to fresh qubits.
Two facts set the scale. First, the state space is exponential β a generic state of qubits carries complex amplitudes, so perfect compression from 6 qubits into 2 would require storing 64 numbers in 4, which is impossible for arbitrary inputs. Autoencoders therefore only work when the data sits on a low-dimensional manifold, exactly as in the classical case: a circuit trained on Haar-random states will fail, while one trained on the ground states of a molecular Hamiltonian across 40 bond lengths has perhaps 40 degrees of freedom and can plausibly fit. Second, no-cloning forbids duplicating the payload, so compression and reuse are destructive β you get one copy of per preparation of the input.
Compression ratio is stated as . A 6-to-2 autoencoder keeps 2 of 6 qubits, ; the benchmark set by Romero and colleagues in 2017 was 4 qubits into 1 with measured fidelities above 0.9 on IBM hardware, which is the number any newer result has to be read against.
Circuit Architecture
The trainable pair has three parts:
- Encoder : qubits in, live qubits and supposedly disentangled out
- Bottleneck: the retained qubits, the only ones that must survive
- Decoder : reconstructs qubits from the bottleneck, usually the time reverse of the encoder
The training loop repeats four steps: prepare , apply encoder then decoder, measure how much population ended up outside the input subspace, and update with parameter-shift gradients.
Published designs are heavily constrained by hardware. Hardware-efficient ansΓ€tze built from the device's native and CNOT layers dominate because each additional layer multiplies the two-qubit error the fidelity has to survive. A 6-qubit encoder with 4 layers of alternating single-qubit rotations and a ring of CNOTs carries 12 CNOT gates; at 1% two-qubit error the best fidelity any such circuit can achieve, before training even starts, is about . Training cannot beat that ceiling, it can only approach it.
Training the Compression
The loss is reconstruction infidelity:
with gradients from the parameter-shift rule:
Two design choices decide whether this trains at all. Loss function: the naive overlap with the input needs a controlled-SWAP test against a stored copy of , which no-cloning does not provide for free; implementations instead minimise population leaking out of the target qubits, a sum of expectations on the discarded register that needs no auxiliary state. Shot budget: each parameter-shift evaluation is two circuit runs, so a 24-parameter encoder costs 48 runs per gradient step, and at 1000 shots each the estimator noise on an infidelity of is already comparable to the signal being optimised.
Locality helps with barren plateaus. The leakage cost depends only on the discarded qubits rather than on the whole register, so its gradient variance falls with the size of the measured region instead of with total qubit count β which is precisely the argument that made local cost functions the standard remedy in variational algorithms.
Python: Training a 6-to-2 Autoencoder
The full loop written on the amplitude vector so nothing is hidden behind a simulator: a layered / encoder with a ring of CNOTs, trained to push population into the subspace where the four discarded qubits read zero.
import numpy as np
from scipy.optimize import minimize
def apply_encoder(state, params, layers=2, n=6):
"""RY/RZ layers interleaved with a ring of CNOTs, applied in place."""
state = state.astype(complex).copy()
idx = np.arange(2 ** n)
p = 0
for _ in range(layers):
for q in range(n):
a, b = params[p], params[p + 1]
p += 2
bit = 1 << q
pairs = idx[(idx & bit) == 0]
v0, v1 = state[pairs].copy(), state[pairs | bit].copy()
state[pairs] = np.cos(a / 2) * v0 - np.sin(a / 2) * v1
state[pairs | bit] = np.sin(a / 2) * v0 + np.cos(a / 2) * v1
state[pairs | bit] *= np.exp(-1j * b)
for q in range(n - 1):
ctrl_bit, tgt_bit = 1 << q, 1 << (q + 1)
sel = idx[(idx & tgt_bit) == 0]
ctrl = sel[(sel & ctrl_bit) != 0]
tgt = ctrl | tgt_bit
state[ctrl], state[tgt] = state[tgt].copy(), state[ctrl].copy()
return state
def leakage(params, training_set, n=6, m=2, layers=2):
"""Population left on the n-m qubits that should end in |0>."""
keep_dim, drop_dim = 2 ** m, 2 ** (n - m)
total = 0.0
for psi in training_set:
amp = apply_encoder(psi, params, layers=layers, n=n).reshape(keep_dim, drop_dim)
total += 1.0 - float(np.sum(np.abs(amp[:, 0]) ** 2))
return total / len(training_set)
rng = np.random.default_rng(3)
n, m, layers = 6, 2, 2
n_params = 2 * n * layers
# The training family lives in a fixed 4-dimensional subspace: the low-manifold
# assumption that makes any compression possible in the first place.
support = [0b000101, 0b001010, 0b010001, 0b100010]
training_set = []
for _ in range(8):
state = np.zeros(2 ** n, dtype=complex)
coeff = rng.normal(size=len(support)) + 1j * rng.normal(size=len(support))
coeff /= np.linalg.norm(coeff)
for c, basis in zip(coeff, support):
state[basis] = c
training_set.append(state)
init = rng.normal(scale=0.3, size=n_params)
print(f"parameters: {n_params} training states: {len(training_set)}")
print(f"leakage before training: {leakage(init, training_set):.4f}")
res = minimize(leakage, init, args=(training_set, n, m), method="COBYLA",
options={"maxiter": 600})
print(f"leakage after training: {res.fun:.4f}")
print(f"compression: {n} qubits -> {m} qubits (ratio {m / n:.2f})")
The two printed leakage numbers tell the story. An untrained circuit spreads population across the full 64-dimensional space, so only the amplitudes of the target subspace land correctly and leakage starts near . After training it falls toward zero because the training states were drawn from a 4-dimensional subspace that a unitary is free to rotate into the target one. Had the same eight states been drawn from the whole 64-dimensional space, no unitary could have compressed them and the optimiser would have stalled near 0.94 β the dimension argument, visible in a single training curve.
Why Denoising Is Harder Than It Looks
Denoising uses the same architecture with a twist: the encoder sees a corrupted state and the loss is judged against the clean target. The mechanism is projection, not restoration. The trained encoder maps onto the manifold it was fitted to, so anything that still overlaps that manifold is recovered and anything pushed off it is mapped to the nearest point on the manifold β which is confidently wrong rather than merely noisy.
The numbers constrain what is achievable. A depolarizing channel with on a 6-qubit state leaves fidelity against the original for a pure input, and a projector-based denoiser can recover only the component that survived. Once reaches 0.2 the overlap with the training manifold is small enough that reconstruction becomes a guess. This is why published denoising results always quote the noise level they were trained at: a model fitted at says nothing about , and a table that omits the training noise level is not reporting a result.
Python: The Fidelity Ceiling
Before spending time on an ansatz, compute what the device allows:
import math
def fidelity_ceiling(cnots, p2q, single_qubit=24, p1q=0.0005,
t1_us=150.0, circuit_us=10.0):
"""Best fidelity any encoder of this shape could reach on this device."""
gate_term = (1 - p2q) ** cnots * (1 - p1q) ** single_qubit
relax_term = math.exp(-circuit_us / t1_us) # relaxation during the run
return gate_term * relax_term
print(f"{'CNOTs':>6} {'p2q=0.001':>11} {'p2q=0.010':>11} {'p2q=0.030':>11}")
for cnots in (4, 8, 12, 24, 48):
row = [fidelity_ceiling(cnots, p) for p in (0.001, 0.010, 0.030)]
print(f"{cnots:>6} " + " ".join(f"{v:>11.4f}" for v in row))
ceiling = fidelity_ceiling(12, 0.010)
reported = 0.95
print(f"\n12 CNOTs at 1% two-qubit error: ceiling {ceiling:.4f}")
print(f"reported {reported}: "
f"{'consistent with the error budget' if reported <= ceiling else 'IMPOSSIBLE - audit the gate count'}")
Reading the output turns into a decision rule. If the reported fidelity sits above the ceiling, either the gate count, the error rate or the fidelity figure is wrong. If it sits just below the ceiling, the encoder is hardware-limited and further training is wasted β the useful work is reducing depth or improving calibration. Only when there is visible headroom is the optimiser the limiting factor, and only then does spending more shots per parameter-shift evaluation make sense.
Choosing Between the Alternatives
Three comparisons decide whether a quantum autoencoder is the right tool at all:
| Goal | Prefer | Why |
|---|---|---|
| Store a quantum state you must re-prepare | quantum autoencoder | only compression scheme that respects no-cloning |
| Store measurement data | classical autoencoder | the data is already classical, and 64-wide arrays are free |
| Remove gate noise | dynamical decoupling or error correction | noise is added after compression, not encoded in the state |
| Reduce circuit depth | compilation and circuit cutting | depth is a compile-time property, not an information property |
The second row matters most in practice. Datasets described as "quantum" usually arrive as bitstrings from a device; a classical autoencoder trained on those bitstrings costs nothing to run, is trivially invertible, and is the correct default until a coherent state actually has to be held.
Applications
| Application | Input | Output | Practical value |
|---|---|---|---|
| Quantum data compression | -qubit state | -qubit bottleneck | fewer qubits held per sample |
| Denoising | noisy state | manifold-projected state | gain only up to the training noise level |
| Feature extraction | full state | latent amplitudes | smaller downstream classifier |
| Syndrome compression | stabiliser register | parity bits | fewer logical measurements before decoding |
| Transfer learning | source-domain state | shared latent space | fewer training circuits on the target domain |
The most defensible current use is the fourth: stabiliser syndromes are highly structured and mostly zero, so compressing them before classical decoding is a genuinely low-risk win with a clear baseline. The least defensible is presenting compression of Haar-random states as a result β the dimension lower bound on that task is explicit, and any reported near-unit fidelity implies a restricted input family that must be named in the caption.
Common Mistakes
Reporting compression of Haar-random states without naming the restriction
Fix: State the input family explicitly: a generic n-qubit state carries 2 to the n amplitudes, so only data on a low-dimensional manifold compresses without loss
Measuring reconstruction fidelity with a controlled-SWAP against a stored copy of the input
Fix: No-cloning forbids that copy; measure population leakage out of the n minus m discarded qubits instead, which needs only Z expectations on those wires
Comparing a trained fidelity against the ideal 1.0 rather than against the circuit's own noise ceiling
Fix: Compute the ceiling first β 12 CNOT gates at 1 percent error caps fidelity near 0.886 β and quote improvement against that figure
Using a quantum autoencoder on data that has already been measured
Fix: Classical autoencoders handle bitstring datasets at zero run cost; reserve the quantum version for states that must be re-prepared coherently
Key Takeaways
- Compression is possible only when the input family is low-dimensional: generic states need 2 to the n amplitudes, while a 4-dimensional training subspace can be rotated into the bottleneck of a 6-to-2 encoder
- Reconstruction loss is normally measured as leakage out of the n minus m discarded qubits, because no-cloning prevents storing a copy of the input for a controlled-SWAP overlap test
- Circuit depth sets a hard fidelity ceiling before training begins β 12 CNOT gates at 1 percent two-qubit error caps fidelity near 0.886 β so ansatz choice follows hardware error rates rather than expressibility
- Denoising is projection onto the learned manifold: it recovers signal inside the training distribution and produces confidently wrong outputs outside it, which is why results must be quoted against the training noise level