Skip to content

v0.0.2: Tetra, a Leech-lattice codebook the GPU reads as stored

Choose a tag to compare

@pjmalandrino pjmalandrino released this 06 Oct 11:42
· 1122 commits to main since this release

The state of the repository behind version 2 of paper 2, Tetra: Serving Leech-Lattice Quantized
LLMs at 2.7 Bits per Parameter
(preprint, not peer reviewed). The PDF is attached. Every number in
it comes from a log, a preregistration or a CSV in this tree.

What Tetra is

LLVQ (van der Ouderaa et al., arXiv:2603.11021) quantizes LLM
weights in blocks of 24. Each block becomes one point of the Leech lattice Λ₂₄, stored as a 48-bit
code: 2 bits per weight. The codebook behind those 48 bits has more than 10¹⁴ points, so a GPU
cannot keep it as a lookup table.

v0.0.1 worked around this by unfolding every code at load time into a 112-bit record
(Planes14), which the kernel decodes with shifts and masks. That worked, but the kernel then
read 4.804 bits per weight from GPU memory, more than the 4.179 of 4-bit AWQ. At batch 1, where
memory traffic sets the speed, the 2-bit format had lost its advantage.

Tetra is a new codebook on the same lattice, built so that the GPU reads the 48-bit code as it is
stored. It uses the structure of the lattice itself. Λ₂₄ is built on the Golay code, a binary
code of length 24. If the 24 coordinates are read in three groups of eight (three disjoint octads
of the Golay code), the code becomes a trellis: a layered graph with 64 states at each cut, where
every codeword is one path. A Tetra word stores that path (one state and three edge choices), two
parity bits, a gain bit, and three 11-bit indices, one per group of eight, into a single shared
table of 4,096 rank vectors. It is still 48 bits per block.

The kernel decodes a block inside the matrix-vector product with six table loads, three in small
trellis tables and three rows of the 16 KiB rank table, plus two small lookups for the gain and
the norm. Nothing is expanded in memory. Over the 252 projection matrices of Qwen3-4B it reads
2.150 bits per weight, against 4.804 for Planes14 and 4.179 for 4-bit AWQ.

The price of one shared table: each group of eight coordinates is bounded on its own, instead of
the whole block, so Tetra keeps a different set of lattice points than the original codebook. On
Gaussian blocks it has 9.2 % more mean squared error (retention 88.80 % against 91.98 %). On a
model, our measurements cannot tell the two codebooks apart.

Three Qwen3 files at about 2.7 bits per parameter

Three changes around the codebook, none of which touches a lattice code: the scale of each weight
row is retrained against the FP16 model with the codes frozen; the projections that lose the most
are stored as int4; and the embedding tables are stored in 4 bits, which pays for the int4 bytes.

Qwen3-4B Qwen3-8B Qwen3-14B
bits per parameter, whole model 2.73 2.70 2.73
weights on the GPU 1.38 GB 2.76 GB 5.04 GB
MMLU, 14,042 questions (FP16 / AWQ) 63.37 (70.14 / 68.14) 69.58 (75.05 / 73.79) 75.66 (78.88 / 78.12)
GSM8K, 1,319 problems (FP16 / AWQ) 82.49 (92.12 / 89.01) 88.63 (93.25 / 92.95) 92.04 (95.30 / 95.38)
WikiText-2 perplexity (FP16 / AWQ) 12.58 (12.24 / 13.52) 9.71 (8.99 / 9.42) 8.44 (7.98 / 8.29)
decode, batch 1, one L40S, our engine 113.8 tok/s 95.0 tok/s 57.2 tok/s
SHA-256 886391a8… 7bdb9a55… 61db37fe…

AWQ w4g128 takes 5.30 to 5.96 bits per parameter. The files, each with its card, license and
served configuration:

What the measurements say

  • Below 4-bit AWQ on quality, by 4.76, 4.21 and 2.46 MMLU points, for about half its bits per
    parameter. On GSM8K, run through the kernel, the files lose more to FP16 than on MMLU when the
    loss is counted in errors.
  • One size up for about the same memory. Our 8B scores 1.44 MMLU points [0.71, 2.19] above
    AWQ's 4B, and our 14B 1.87 [1.20, 2.57] above AWQ's 8B. On GSM8K the same pairs are not
    separated.
  • Perplexity ranks the files differently. Our 4B is 6.9 % below AWQ in perplexity while it
    scores 4.76 MMLU points under it.
  • Half the bytes is not half the time. On one L40S, with every kernel on the same 252
    matrices, one pass takes 3.734 ms for Tetra, 3.263 ms for AWQ and 11.022 ms for FP16. AWQ is
    still faster.
  • The speed gain depends on the card. On an A100 the Tetra kernel beats our FP16 kernel
    (1.11×) but not cuBLAS (1.14×), and the served files decode slower than FP16 in vLLM.

Running it

git clone https://github.com/pjmalandrino/llvq && cd llvq
hf download Pier-Jean/Qwen3-4B-LLVQ-Tetra-sealed qwen3-4b-sealed.bin --local-dir .
LLVQ_CONFIG=configs/qwen3-4b-tetra-e4.json \
  cargo run --release -p llvq-llm --features cuda --bin chat -- qwen3-4b-sealed.bin cuda

The served path needs an NVIDIA GPU. On Apple silicon only the dense reconstruction runs.

Evidence in the tree

198 measurement journals in docs/mesures/, 33 datasets in docs/data/, and a ledger of 221 paid
jobs totalling $246.45 in docs/data/jobs.csv. 105 preregistrations in proofs/, written before
their first measurement, 96 of them with an OpenTimestamps receipt, and 58 files that record where
a campaign departed from its plan. paper2/PROVENANCE.md names the source of every number in the paper, and
paper2/scripts/check_tables.py stops the build if a table drifts from its CSV. A second number
audit of the paper, docs/mesures/paper2-audit-2026-10-06.txt, found no wrong table cell.

What this release does not claim

  • Not faster than 4-bit AWQ. Its kernel is faster on both cards we measured.
  • Two data-center GPUs (L40S and A100), and no consumer GPU, the hardware this work targets.
  • MMLU and perplexity are scored on the dense reconstruction, not through the kernel. GSM8K is
    scored through it.
  • The int4 choices were made on MMLU test questions, so the MMLU scores carry a selection bias
    that was not measured.
  • One calibration draw per size, batch 1 and short context only.

Code under MIT OR Apache-2.0. The model files inherit Apache 2.0 from Qwen3.