2024 NLP/LLM Hybrid Q-C

Quantum Transformers for Language: Quixer · HyQuT · QTHA

Khatri, Matos, Coopmans et al. (Quixer, 2024); Kong et al. (HyQuT, 2025)
Quixer: arXiv:2406.04305 (Jun 2024) · HyQuT: arXiv:2511.10653 (Nov 2025)

Contents

  1. Landscape of Quantum Transformers
  2. Quixer: Full Quantum Self-Attention
  3. HyQuT: Hybrid Q/K Classical, Quantum V
  4. QTHA: Token-based Hybrid Attention
  5. Architecture Comparison
  6. NISQ Bottlenecks & Outlook

1. Landscape of Quantum Transformers

The Transformer architecture dominates NLP and vision. Its core operation — multi-head self-attention — involves $O(n^2 d)$ complexity for sequence length $n$ and dimension $d$. Quantum approaches aim to reduce this via: (a) quantum amplitude encoding of embeddings, (b) quantum inner product estimation for attention scores, and (c) quantum projection for key/query/value matrices.

Three strategies:
· Full quantum (Quixer): attention computed via quantum inner product estimation
· Partial hybrid (HyQuT): classical attention scores, quantum value projection
· Token-level hybrid (QTHA): per-token quantum circuits for compatibility

2. Quixer: Full Quantum Self-Attention

Quixer (Khatri, Matos, Coopmans et al., 2024) implements a fully quantum self-attention mechanism using Linear Combination of Unitaries (LCU) and QSVT primitives to realise attention as a quantum operation. It is the first quantum transformer applied to a practical language modelling task (Penn Treebank).

Quantum State Preparation

Token embeddings $\mathbf{x}_1, \ldots, \mathbf{x}_n \in \mathbb{R}^d$ are loaded as quantum states:

$$|\mathbf{x}_i\rangle = \sum_{j=1}^{d} x_{ij} |j\rangle \quad \text{(amplitude encoding)}$$
Eq. (1) — Token embeddings as quantum amplitudes

Quantum Inner Product for Attention

The attention weight between tokens $i$ and $j$ requires computing $\mathbf{q}_i \cdot \mathbf{k}_j / \sqrt{d}$. Quixer uses the SWAP test to estimate this inner product:

$$\Pr[\text{SWAP test}] = \frac{1 + |\langle \phi_i | \psi_j \rangle|^2}{2}$$
Eq. (2) — SWAP test for inner product estimation

More precisely, Quixer uses the Hadamard test with controlled-SWAP to extract signed inner products:

$$\langle q_i | k_j \rangle = \text{Re}\langle \phi |( H \otimes \text{CSWAP}) |\phi\rangle$$
Eq. (3) — Signed inner product via Hadamard test

Quixer Architecture

Input tokens: x₁, x₂, ..., xₙ ∈ ℝᵈ
         │
         ▼  [QRAM loading — O(log d) depth]
    |x₁⟩, |x₂⟩, ..., |xₙ⟩  (quantum states)
         │
         ▼  [Quantum Q,K,V projection via PQC(θ)]
    |q₁⟩, |k₁⟩, |v₁⟩, ...   (projected states)
         │
         ▼  [Quantum inner product estimation]
         │    For all pairs (i,j):
         │    aᵢⱼ = ⟨qᵢ|kⱼ⟩  via Hadamard test
         │
         ▼  [Classical softmax — executed on classical CPU]
         │    αᵢⱼ = softmax(aᵢⱼ / √d)ⱼ
         │
         ▼  [Quantum linear combination of |vⱼ⟩ states]
         │    |outᵢ⟩ = Σⱼ αᵢⱼ |vⱼ⟩    (quantum superposition)
         │
         ▼  [Quantum measurement → classical output]
    outᵢ ∈ ℝᵈ   (attention-weighted embeddings)
         │
         ▼  [Classical FFN + residual]
    Next layer or output

Quixer Complexity

$$T_{\text{Quixer}} = O\!\left(n^2 \cdot \text{poly}(\log d, 1/\epsilon)\right)$$
Eq. (4) — Quixer time complexity ($\epsilon$ = inner product estimation error)

vs. classical: $O(n^2 d)$. Advantage when $d \gg \text{poly}(\log d)$, i.e. for large embedding dimensions — contingent on efficient QRAM and fault-tolerant hardware.

3. HyQuT: Hybrid Quantum Transformer

HyQuT (Kong et al., Nov 2025) takes a hybrid approach: integrating VQCs into the Transformer at both 8M and 150M parameter scales. Just 10 qubits with 80 quantum gates replace ~10% of classical parameters in the 150M model while achieving comparable generation quality.

Motivation

Attention weights $\alpha_{ij} = \text{softmax}(Q K^\top / \sqrt{d_k})_{ij}$ are sparse and interpretable — classical computation is efficient. The value projection $V = W_V X$ is the dominant computation in large models and benefits most from quantum expressibility.

HyQuT Attention

\begin{aligned} Q &= W_Q^{\text{class}} X \quad \text{(classical projection)} \\ K &= W_K^{\text{class}} X \quad \text{(classical projection)} \\ V &= \text{VQC}(\boldsymbol{\theta}_V, X) \quad \text{(quantum value projection)} \\ \text{MHA} &= \text{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right) V \end{aligned}
Eq. (5) — HyQuT hybrid attention decomposition

VQC for Value Projection

The quantum value projection uses an $\ell$-layer VQC with data re-uploading:

$$\text{VQC}(\boldsymbol{\theta}, \mathbf{x}) = \langle 0 | U^\dagger(\boldsymbol{\theta}, \mathbf{x})\, O\, U(\boldsymbol{\theta}, \mathbf{x}) | 0 \rangle$$
Eq. (6) — VQC expectation value as value projection
HyQuT Block:

Input X (N×d)
   │
   ├──[Classical W_Q]──→  Q (N×d_k)  ─┐
   ├──[Classical W_K]──→  K (N×d_k)  ─┤─→  softmax(QKᵀ/√d_k) → α (N×N)
   │                                    │                               │
   └──[Quantum VQC(θ)]──→ V (N×d_v) ←─┘         α · V → Output       │
            │                                          ↑                │
            │  VQC internals:                          └────────────────┘
            │  |0⟩──[Enc(x)]──[VQC layer 1]──...──[VQC layer ℓ]──[Meas]
            │  Enc(x): angle encoding xᵢ → Ry(xᵢ) rotations
            │  VQC layer: Ry(θ) + CNOT entangling

Classical FFN
   │
   ▼
Layer Output

Data Re-uploading

HyQuT uses data re-uploading to increase effective circuit depth without increasing qubit count:

$$U(\boldsymbol{\theta}, \mathbf{x}) = \prod_{\ell=1}^{L} W_\ell(\boldsymbol{\theta}_\ell)\, S(\mathbf{x})$$
Eq. (7) — Data re-uploading: alternating trainable gates $W_\ell$ and encoding $S(\mathbf{x})$

This makes the VQC a universal function approximator on its input domain (Pérez-Salinas et al. 2020).

4. QTHA: Quantum Token-based Hybrid Attention

QTHA (Quantum Token-based Hybrid Attention) computes per-token quantum circuits to parameterise the compatibility function between queries and keys.

Per-token Quantum Compatibility

For token $i$, the quantum circuit $\mathcal{C}_i$ processes the query $\mathbf{q}_i$ and produces a quantum state encoding its "attention signature":

|\psi_i(\mathbf{q}_i)\rangle = U(\boldsymbol{\theta}_{\text{attn}}, \mathbf{q}_i)|0\rangle
Eq. (8) — Per-token quantum state for query representation

Attention weight between token $i$ (query) and $j$ (key):

$$a_{ij} = \langle \psi_i(\mathbf{q}_i) | M_j | \psi_i(\mathbf{q}_i) \rangle$$
Eq. (9) — Quantum inner product compatibility (observable $M_j$ depends on $\mathbf{k}_j$)

QTHA Architecture

For each query token i:
   qᵢ ∈ ℝᵈ
      │
      ▼  [Angle encoding]
   |0⟩──[Ry(q_i1)]──[Ry(q_i2)]──...──[CNOT layers]──[Ry(θ)]──
                                                              │
                                              ┌──────────────┘
                                              │  Quantum state |ψᵢ⟩
                                              │
   For each key token j:                      ▼
   kⱼ ∈ ℝᵈ ──[encode into observable Mⱼ]──  ⟨ψᵢ|Mⱼ|ψᵢ⟩ = aᵢⱼ
                                              │
                                              ▼
                             aᵢⱼ for all j ──→ softmax ──→ αᵢⱼ
                                                                │
                             αᵢⱼ · Vⱼ ─────────────────────→ outputᵢ

5. Architecture Comparison

Model Quantum Components Q Complexity NISQ Feasibility Potential Advantage
Quixer Full Q attention (QRAM + inner product) $O(n^2 \log d)$ Needs QRAM — not yet NISQ Exponential in $d$
HyQuT Quantum V; Classical Q, K $O(n \cdot \text{VQC cost})$ NISQ compatible Expressibility of V
QTHA Per-token Q compatibility $O(n \cdot \text{VQC cost})$ NISQ compatible Attention pattern richness
QViT Quantum Q, K, V projections (orthogonal) $O(n^2 \log d)$ circuit NISQ compatible $O(n)$ parameters

6. NISQ Bottlenecks & Outlook

QRAM bottleneck (Quixer): Efficient QRAM with $O(\log N)$ depth and $O(N)$ qubits is hardware-unproven at scale. Without QRAM, amplitude loading is $O(N)$ depth — eliminating the speedup.
Barren plateaus: Generic VQC ansätze in HyQuT and QTHA suffer from BP for large qubit counts. Mitigate via ADAPT-VQE-style structured ansätze or Quantum-PEFT.
Measurement overhead: Extracting all attention weights requires $O(n^2)$ measurement shots — polynomial but large for current hardware shot budgets.
Classical simulation: Small-scale experiments (up to ~20 qubits) are classically simulable. True quantum advantage only visible at $n \gtrsim 50$ qubits with fault-tolerant gates.
Near-term outlook: HyQuT and QTHA are the most NISQ-ready — they use small VQCs for value projection and attention compatibility respectively, and can run on 10–20 qubit hardware with acceptable circuit depth. Quixer is a long-term target requiring fault-tolerant QRAM hardware.

Related Papers