Paper commentary
NestQuant: Nested Lattice Quantization for Matrix Products and LLMs
NestQuant quantizes LLM weights, KV cache and activations using nested lattices
- Problem Simple rounding wastes bits when activations and KV cache are quantized, because their entries don't fit a uniform grid.
- Method NestQuant swaps the uniform grid for a Voronoi code on the 8-dimensional Gosset lattice, after dividing each row by its L2 norm.
- Results NestQuant scored 6.6 perplexity on wikitext2 with Llama-3-8B quantized to 4 bits, against 7.3 for SpinQuant.
Why low-bit activations and KV cache are hard
Simple rounding wastes bits when activations and KV cache are quantized, because their entries don't follow the shape a uniform grid expects. Weights can already be pushed to 3 or 4 bits with little loss, so weight-only methods are well established. Quantizing the KV cache and the activations has been much more challenging, which keeps full quantization an open problem.
The second goal of PTQ is to accelerate inference, and the KV cache matters most during generation, when the GPU becomes memory-bound.
The usual recipe divides the input vector by its L∞ norm so that entries fall in [−1, 1], then applies uniform quantization. This is suboptimal for two reasons, and the second one is much more serious. The bigger loss is the shaping gain: Gaussian-like entries typically lie inside a black circle, so grid elements outside it are almost never used.
In 2D, uniform quantization wastes about 32% of its allocated bitstrings on vectors outside the circle.
The authors call this loss the shaping gain, so the question becomes how to place codewords where the data actually lives. Instead of normalizing by the L∞ norm, NestQuant normalizes by the L2-norm and uses points inside the Voronoi region of a Gosset lattice. Nested hexagonal lattices waste only 15% of bitstrings in the 2D example, which lets NestQuant use a finer grid at the same rate.
Random rotation handles the other problem: inputs that differ from iid Gaussians, which perform poorly under quantization. Multiplying by a random orthogonal matrix U makes the coordinates of a chunk close to iid Gaussian, so the quantizer sees the distribution it was designed for.
The key idea: Voronoi codes on a Gosset lattice
NestQuant replaces the uniform grid with a Voronoi code built on the 8-dimensional Gosset lattice. Before encoding, each row is divided by its L2 norm, so the entries follow a predictable scale. The quantizer then places its points inside the Voronoi region of the Gosset lattice instead of inside a cube. Those points waste fewer bitstrings on rare vectors, which lets the grid be finer at the same rate.
Figure 2 shows this effect in two dimensions, with typical inputs inside a black circle. Uniform quantization wastes about 32% of its allocated bitstrings on vectors outside the circle. Nested hexagonal lattices waste only 15% in the same picture, so they allow a finer grid at the same rate. The authors expect the gain to grow in higher dimensions, but NestQuant itself uses the 8-dimensional Gosset lattice, not the hexagonal one.
Enumerating every point inside the circle would avoid the waste, but it is too slow to run at inference time.

Figure 2 : Demonstrating advantage of NestQuant in 2D. Typical weights and activations are vectors inside the black circle. Uniform quantization wastes about 32% of allocated bitstrings for vectors outside of the circle, while nested hexagonal lattices only wastes 15% (explicitly enumerating points inside the circle to avoid the waste is too slow to do at runtime). This allows NestQuant to use finer grid while quantizing to the same rate R. The gain becomes much more dramatic in higher dimensions.
Original paper · CC BY 4.0 · Semyon Savkin, Eitan Porat, Or Ordentlich, Yury Polyanskiy · NestQuant: Nested Lattice Quantization for Matrix Products and LLMs · Original paper figure · Extracted the figure area from page 4 of the original PDF.Inputs that don't look Gaussian need a second step, so NestQuant multiplies them by a random orthogonal matrix U. After rotation, small chunks of UX look almost like iid Gaussian vectors, which matches the quantizer's design. In a matrix product, AB equals (AU)(U transposed B), so outliers are spread out without changing the product.
For each block of d entries, Algorithm 3 tries each of the k scaling coefficients and keeps the one with the smallest error. The block then stores its quantized codeword together with the index of the chosen scaling coefficient.
Why the Gosset lattice and a union of scales
Granular error is measured by the normalized second moment of a lattice, and the integer lattice Z gives a value of 1/12 in one dimension. The optimal normalized second moment among all lattices approaches 1/(2πe) from above as the dimension grows. High-dimensional lattices can gain a factor of 1.42329 over Z, and the Gosset lattice achieves a gain of 1.16.
The authors report the normalized second moment of the Gosset lattice as about 0.0716821. Because the Gosset lattice has a fast decoding algorithm and a small normalized second moment, it fits the design criteria that the authors set for the base lattice.
A codebook would need infinitely many bits to name every lattice point, so NestQuant keeps only a subset, called the shaping region. Points that fall outside this region cause overload errors, which can be much larger than granular errors. Voronoi codes use the same lattice for quantization and shaping, with the region qV_Λ and q equal to 2^R, so R equals log2 q.
Overload is hard to avoid in dimension 8, because the norm of an 8-dimensional Gaussian vector isn't tightly concentrated. A single Voronoi code would need a large β to keep overload rare, and that costs distortion. So NestQuant takes a union of k Voronoi codes at scales β1 < ... < βk, and each block uses the scale that fits it best. The overall rate becomes R + (1/d) log2 k, and nvcomp compression of the chosen betas reduces that rate penalty.
The authors argue that SpinQuant's cubic shaping pays an O(ln d) multiplicative gap in MSE.
How a block is encoded and decoded
The encoder first finds the nearest Gosset lattice point p for a block, then keeps only the coset that p belongs to. It sends v mod q, where v is the integer coordinate vector of p, so each entry costs log2 q bits. The decoder receives only this coset, so it knows p only up to a multiple of qΛ. It then returns the minimum-energy point of that coset, which lies inside qV_Λ.
The reconstruction equals the nearest lattice point exactly when that point lies in qV_Λ. When the nearest point falls outside qV_Λ, the quantizer is in overload. Algorithm 1 computes p and its coordinates through the inverse generator matrix, while Algorithm 2 multiplies the code back by G. In the experiments, the base lattice is the Gosset lattice E8 with d = 8, built from D8 and D8 plus one half.
Algorithm 3 starts by computing a normalization coefficient s, the L2 norm of the input vector, and rescales the vector with it. It then splits the rescaled vector into blocks of size d. For each block, Algorithm 3 tries each of the k scaling coefficients β and encodes the block divided by that coefficient. It decodes each candidate, multiplies it back by the coefficient, and keeps the choice with the smallest squared error.
The output is the array of integer codes QA, the index of the chosen coefficient for each block in B, and the scale s. Algorithm 4 computes a dot product block by block from two such representations, decoding both sides without full dequantization. Each block product is weighted by the two chosen coefficients before the results are summed.
The authors use this dot product path for linear layers in the generation stage and for querying the KV cache.
With q = 14 and k = 4, the 4-bit setting gives 3.99 bits per entry with zstd and 4.06 without. The expected rate adds an entropy term over the usage probabilities of the coefficients to log2 q. The coefficient set itself comes from the dynamic programming procedure in Appendix F.
Rotations, calibration and QA-LDLQ in NestQuant
Each linear layer's weight-activation pair is rotated by a Hadamard matrix H, and the layer output stays the same. For an input size that is a power of two, H comes from Sylvester's construction. Otherwise, the input size is split as n = 2^k m, with a small Hadamard matrix H1 of size m combined with a Sylvester matrix H2 of size 2^k through a Kronecker product.
In the power-of-two case, multiplying an r × n matrix by H costs O(rn log n), which the authors call negligible next to the other computational costs. The rotation can run online, so the runtime cost stays small even for the second case.
The weights absorb the Hadamard rotation, and activations are rotated and quantized before each linear layer at run time. Keys and queries are rotated too, because the rotation leaves the attention scores unchanged. Keys and values are quantized before they enter the KV cache, so every weight, activation, key and value passes through Algorithm 3.
Figure 4 shows this scheme for multi-head attention layers.
Calibration data gives a Hessian H of size d × d for each linear layer with in-dimension d. The authors start from an initial set of scaling coefficients β̂ and simulate LDLQ quantization for each weight with them. This produces a set of 8-dimensional vectors, and a dynamic programming pass in Appendix F then picks the optimal β values for each weight matrix.
Standard LDLQ and GPTQ minimize the weight error on unquantized activations, which becomes significantly suboptimal once activations are quantized too. QA-LDLQ instead minimizes the expected squared norm of δ(U) = WX − U(X + Z), where Z is the activation quantization error. Lemma 4.2 shows the minimizer equals the solution of a problem on W̃ = W H(H + J)^{-1} with Hessian H + J, where H = E[XX^T] and J = E[ZZ^T].
So QA-LDLQ computes W̃ first and then runs the standard LDLQ solver on it. In the paper the target is weights quantized with QA-LDLQ and precomputed β, so the method uses both steps at once.
The authors skip expensive fine-tuning, so they don't optimize rotation matrices or run post-quantization training. They cite the optimized rotations of SpinQuant and QuIP# as examples of such fine-tuning. Their goal is to demonstrate the basic primitive rather than the absolute state-of-the-art numbers.
Synthetic Gaussian matrices against the bound
The authors multiply two 4096 by 4096 matrices with iid unit-normal entries and measure the mean L2 loss per entry. The uniform baseline is the L∞-scaled quantizer that SpinQuant uses, which the paper compares against NestQuant on the same product. For NestQuant, the search runs over q and k, and the best subset of scaling coefficients β is picked from 12 times the set 1 to 50.
Bits per entry are computed as log2 q plus a term built from the probabilities p(βi) of each coefficient being used. The authors plot this efficient frontier of bits per entry against root mean L2 loss in Figure 3.
The information-theoretic bound comes from a Gaussian source, where any compressor at rate R must satisfy D ≥ D(R) with D(R) = 2^(-2R). For inner products of independent Gaussian vectors, the bound says the squared error is at least nΓ(R). The function Γ(R) depends on R*, which is approximately 0.906 and solves a transcendental fixed-point equation.
The authors use n-dimensional lattices built as Cartesian products of Gosset lattice copies, since the lattices in the proof lack efficient decoding. Figure 3 compares NestQuant, SpinQuant with cubic shaping, and the lower bound from (1). The authors report that NestQuant is reasonably close to the fundamental limit and significantly outperforms SpinQuant.
Llama results against 4-bit baselines
The headline test quantizes the weights, KV cache and activations of Llama-3-8B to 4 bits and reports wikitext2 perplexity at context length 2048. The unquantized model scores 6.14, while the fully quantized NestQuant reaches 6.6. The abstract puts the perplexity gap reduction above 55% against SpinQuant at 7.3, OstQuant at 7.3 and QuaRot at 8.2.
Table 1 lists QuaRot at 8.4 in the same full setting, so the paper prints two different QuaRot values. The NestQuant runs use q = 14 and k = 4, with 3.99 bits per entry and 4.06 bits without zstd.
Table 2 extends the comparison to five Llama models, grouping each method by its weight, KV cache and activation bit widths. In the 4-4-4 setting on Llama-3-8B, NestQuant scores 6.63, compared to 7.3 for SpinQuant and 8.16 for QuaRot. On Llama-3-70B in the same setting, NestQuant scores 3.61, against 4.01 for OstQuant. Under weights-only quantization, NestQuant reaches 6.31 on Llama-3-8B, against 6.53 for OstQuant.

Table 2 : The wikitext2 perplexity at context window of 2048 for various quantization methods of Llama models.
Original paper · CC BY 4.0On the zero-shot suite, the full setting averages 0.71 for NestQuant, compared to 0.68 for SpinQuant. Those averages sit close together, so the perplexity gap carries most of the difference. Without the LDLQ correction, the full quantization setting reaches a perplexity of 6.8. The authors still count 6.8 as better than the compared methods.
They also report that W4A4KV4 beats previously reported W4A4KV16 results for every model except Llama-2-7B.
How the rate trades against perplexity
Table 3 shows how NestQuant's perplexity on Llama-3-8B changes as the nesting ratio q drops from 14 to 8. With zstd compression of the scaling coefficients, the bit rate falls from 3.99 to 3.18 bits per entry. Without compression, the same change moves the rate from 4.06 to 3.25 bits per entry. In the full W+KV+A regime, perplexity rises from 6.633 to 7.989 over that range.
The weight-only column moves much less, from 6.308 to 6.700.

Table 3 : Wikitext2 perplexity of NestQuant quantization of Llama-3-8B at different rates. The "bits" column is the bit rate per entry with zstd compression of scaling coefficients, and "bits (no zstd)" is the bit rate without compression. The "W", "W+KV", and "W+KV+A" describe the quantization regime (whether weights, KV cache, or activations are quantized). The perplexity of non-quantized model is 6.139
Original paper · CC BY 4.0The unquantized Llama-3-8B scores 6.139, so every quantized row sits above that floor. At every q, adding the KV cache and activations raises perplexity on top of the weight-only result. The gap between the regimes widens as q shrinks, and it is largest at q = 8 in the W+KV+A column. Smaller q therefore acts as a direct knob between bit rate and accuracy in these runs.
For the comparisons with other methods, the authors fix q = 14 and k = 4. The number of scaling coefficients k is set to 4 for all of these Llama runs. Appendix H.1 gives the rationale for choosing k = 4, and this section doesn't repeat it. The reported bit rates count the zstd-compressed scaling coefficients, so they sit slightly below the uncompressed column.
They didn't test values of q outside the range 8 to 14 in this table.
Where NestQuant's claims stop
The authors explain why they stopped short of lookup-table codebooks for activations: the QuIP# approach uses a lookup table for ball shaping. They say this seems possible only for quantizing weights, because the complexity makes runtime implementation too slow. Their footnote notes that QuIP# exploits symmetries of E8 for a 2-bit quantizer with a lookup table of size 28.
The authors believe that approach is still too slow, and it doesn't naturally extend to different quantization rates. NestQuant avoids this by using Voronoi codes, whose encoding and decoding complexity doesn't depend on R.
Plain LDLQ breaks down when activations are quantized too, so the authors introduce QA-LDLQ as a correction. Using the original LDLQ on Llama-3-70B yields infinite perplexity in the W4A4 setting, because of significant outliers in layer 0. The method therefore depends on QA-LDLQ for the full W4A4 quantization they report.
The experiments cover only the Llama family, so the authors don't claim results for other model families. They didn't apply fine-tuning such as rotation optimization or post-quantization training, because their goal was the basic primitive. The bit rates in the tables use zstd compression for the scaling coefficient indices, and the uncompressed rate is listed separately.
Paper info
- Authors
- Semyon Savkin, Eitan Porat, Or Ordentlich, Yury Polyanskiy
- Venue
- arXiv · Preprint
- First published
- 2025-2-13
- Added
- 2026-10-31
- Updated
- 2025-7-26
- Version
- v3
- arXiv
- 2502.09720
- Category
- cs.LG · cs.AI · cs.IT
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
Post-training quantization (PTQ) has emerged as a critical technique for efficient deployment of large language models (LLMs). This work proposes NestQuant, a novel PTQ scheme for weights and activations that is based on self-similar nested lattices. Recent works have mathematically shown such quantizers to be information-theoretically optimal for low-precision matrix multiplication. We implement a practical low-complexity version of NestQuant based on Gosset lattice, making it a drop-in quantizer for any matrix multiplication step (e.g., in self-attention, MLP etc). For example, NestQuant quantizes weights, KV-cache, and activations of Llama-3-8B to 4 bits, achieving perplexity of 6.6 on wikitext2. This represents more than 55% reduction in perplexity gap with respect to unquantized model (perplexity of 6.14) compared to state-of-the-art Metas SpinQuant (perplexity 7.3), OstQuant (7.3) and QuaRot (8.2). Comparisons on bigger models (up to 70B) and on various LLM evaluation benchmarks confirm uniform superiority of NestQuant.
Quote from the paper
Semyon Savkin, Eitan Porat, Or Ordentlich, Yury Polyanskiy (2025). NestQuant: Nested Lattice Quantization for Matrix Products and LLMs. arXiv:2502.09720v3. https://arxiv.org/abs/2502.09720v3
BibTeX
@misc{savkin2025nestquant,
title = {{NestQuant: Nested Lattice Quantization for Matrix Products and LLMs}},
author = {Semyon Savkin and Eitan Porat and Or Ordentlich and Yury Polyanskiy},
year = {2025},
eprint = {2502.09720},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2502.09720v3}
}