---
title: 'Block-GTQ: RoPE-Aware KV-Cache Quantization'
url: https://www.emergentmind.com/topics/block-gtq
type: topic
---

# Block-GTQ: RoPE-Aware KV-Cache Quantization

Block-GTQ is a RoPE-aware bit-allocation method for key-cache quantization in long-context transformer inference. It is designed for the setting in which KV-cache memory footprint and memory bandwidth dominate decoding latency and feasibility, and it departs from flat-vector key quantization by exploiting the fact that, under Rotary Positional Embeddings (RoPE), a key’s contribution to a future attention logit decomposes into a position-dependent sum over two-dimensional frequency blocks. In this formulation, key-cache compression becomes a block-wise rate-allocation problem: RoPE blocks with larger query-key energy are assigned more bits, while lower-impact blocks are assigned fewer bits. The method is built on TurboQuant-MSE (TQ-MSE), uses label-free calibration, and couples an analytically motivated error proxy with a greedy integer allocator that is proved optimal for the stated objective [2606.24033].

## 1. Problem setting and RoPE block structure

Block-GTQ is motivated by autoregressive decoding, where every new token streams cached keys and values for all previous tokens. In that regime, quantizing the KV cache reduces both memory footprint and HBM traffic, but the perturbation mechanisms for keys and values differ: values affect the post-softmax mixture, whereas keys perturb the pre-softmax logits seen by future queries. The method therefore focuses its non-uniform allocation on keys, while values are quantized uniformly with TQ-MSE in the reported deployment configurations [2606.24033].

The central structural observation is that RoPE changes the natural unit of key quantization. Let the head dimension be $d_h$ and define $L=d_h/2$. A query and key head are partitioned into $L$ two-dimensional RoPE blocks indexed by $m\in\{0,\dots,L-1\}$, each associated with frequency $\theta_m$. For query position $p_q$, key position $p_k$, and relative offset $\Delta p=p_q-p_k$, the RoPE-transformed query-key dot product decomposes as
$$
q'\!\cdot k'
=
\sum_{m=0}^{L-1}
\Big[
(q_{2m}k_{2m}+q_{2m+1}k_{2m+1})\cos(\theta_m\Delta p)
+
(q_{2m+1}k_{2m}-q_{2m}k_{2m+1})\sin(\theta_m\Delta p)
\Big].
$$
This decomposition is block-diagonal in the RoPE basis: each logit is a sum of independent two-dimensional block contributions modulated by $\cos(\theta_m\Delta p)$ and $\sin(\theta_m\Delta p)$ [2606.24033].

The same block structure governs quantization error. If $\hat{k}$ is the decoded key and $e^{(m)}=k^{(m)}-\hat{k}^{(m)}$ is the error in block $m$, then the induced logit perturbation satisfies
$$
\big|q^\top R(\Delta p)(k-\hat{k})\big|
=
\Big|\sum_m q^{(m)\top}R(\theta_m\Delta p)e^{(m)}\Big|
\le
\sum_m \|q^{(m)}\|_2\,\|e^{(m)}\|_2,
$$
because each $R(\theta_m\Delta p)$ is a $2\times 2$ rotation. There are no cross-block terms in this bound, and RoPE preserves each block’s $\ell_2$ norm. This is the basis for treating key quantization as a block-wise allocation problem rather than a coordinate-wise or flat-vector problem [2606.24033].

## 2. Sensitivity scores and the rate-allocation objective

The ideal block sensitivity in Block-GTQ is the expected squared query-key energy
$$
s_m^* := \mathbb{E}\!\left[\|q^{(m)}\|_2^2\cdot \|k^{(m)}\|_2^2\right].
$$
The paper states that this quantity upper-bounds the expected squared logit error when combined with the block’s squared reconstruction error, but it also notes that direct estimation of $s_m^*$ requires paired $Q$–$K$ products and is noisy on short calibration. The method therefore uses a label-free AM–GM surrogate
$$
s_m := \tfrac{1}{2}\,\mathbb{E}\!\left[\|q^{(m)}\|_2^2+\|k^{(m)}\|_2^2\right]
\qquad\text{with}\qquad
s_m^*\le s_m.
$$
In grouped-query attention (GQA), for layer $\ell$, KV head $h$, RoPE block $m$, query-head group $G(h)$, and calibration length $N$, the instantiated score is
$$
s_{\ell,h,m}
=
\frac{1}{N|G(h)|}\sum_{t=1}^N \sum_{g\in G(h)} \|q^{(m)}_{\ell,g,t}\|_2^2
+
\frac{1}{N}\sum_{t=1}^N \|k^{(m)}_{\ell,h,t}\|_2^2.
$$
The score is RoPE-invariant and depends only on marginal second moments of pre-RoPE queries and keys [2606.24033].

The local quantizer reused by Block-GTQ is TQ-MSE. For a nonzero vector $x$, TQ-MSE normalizes by its radius, applies a shared orthogonal rotation, scalar-quantizes each rotated coordinate at $b$ bits, and rescales by the original radius. Its mean-squared reconstruction error obeys
$$
\mathbb{E}\!\left[\|x-\hat{x}\|_2^2\right]
\le
C_{TQ}\,\|x\|_2^2\cdot 4^{-b},
$$
with positive constant $C_{TQ}$. Under the paper’s block-error accounting, this leads to the weighted proxy
$$
J_{\ell,h}(b)=\sum_{m=0}^{L-1} s_{\ell,h,m}\cdot 4^{-b_m},
$$
to be minimized over integer block bit-widths $b_m$ subject to a head-level budget [2606.24033].

The resulting optimization problem is
$$
\min_{\{b_m\in\mathbb{Z}\}}
\sum_m s_{\ell,h,m}\cdot 4^{-b_m}
\quad\text{s.t.}\quad
\sum_m b_m = B,\;\;
b_{\min}\le b_m\le b_{\max},
$$
where $B$ is typically $L\cdot b_{\mathrm{avg}}$ for average bit budget $b_{\mathrm{avg}}$. The concrete interpretation is that RoPE blocks with larger sensitivity scores should receive more bits because their contribution to future logits is larger [2606.24033].

## 3. Greedy allocation and calibration pipeline

Block-GTQ assigns bits by marginal gain. Increasing block $m$ from $b_m$ to $b_m+1$ reduces the objective by
$$
\Delta_m(b_m)
=
s_{\ell,h,m}\left(4^{-b_m}-4^{-(b_m+1)}\right)
=
3\,s_{\ell,h,m}\cdot 4^{-b_m}.
$$
These gains are positive and decay geometrically with each additional bit on the same block. The paper proves that a simple greedy rule is exactly optimal for the stated integer program: repeatedly allocate the next bit to the block with the largest current marginal gain, subject only to the per-block upper bound. The proof is by exchange argument over “prefix-constrained” geometric gain sequences [2606.24033].

The implementation pipeline is layer-wise and head-wise. First, pre-RoPE queries and keys are collected on a short unlabeled calibration prefix, with the paper giving $N=2048$ WikiText-2 tokens as an example. Second, each head is split into $L=d_h/2$ RoPE blocks and the scores $s_{\ell,h,m}$ are computed. Third, the allocator chooses $b_{\min}$, $b_{\max}$, and total budget $B=L\cdot b_{\mathrm{avg}}$, initializes all blocks at $b_{\min}$, and greedily distributes the remaining budget. The algorithmic description uses a max-heap keyed by $\Delta_m=2\,s_{\ell,h,m}\cdot 4^{-b_m}$, which the paper notes gives the same ordering as the analytic marginal gain up to a constant. The resulting complexity is
$$
O\!\left((B-L\cdot b_{\min})\log L\right),
$$
which is negligible for typical head sizes such as $d_h=128$, where $L=64$ [2606.24033].

A worked example in the paper considers one head with $d_h=8$, hence $L=4$, block energies $[10.0,5.0,1.0,0.5]$, average budget $b_{\mathrm{avg}}=2$, and bounds $b_{\min}=1$, $b_{\max}=4$. Starting from $[1,1,1,1]$, the greedy updates allocate the four extra bits in the order $m=0$, $m=1$, $m=0$, $m=2$, yielding the final allocation $[3,2,2,1]$. This illustrates the stated geometric trade-off: the highest-energy block receives repeated upgrades until its marginal gain falls below that of a lower-energy block still at low precision [2606.24033].

## 4. Quantizer materialization and packed-cache serving

After bit allocation, Block-GTQ groups blocks with the same assigned bit-width into “same-rate” segments. Post-RoPE key coordinates in each segment are concatenated and encoded with one TQ-MSE encoder at that segment’s rate. Values are not part of the RoPE logit decomposition and are therefore encoded with uniform TQ-MSE at the selected V budget. The reported experiments separate K-only diagnostics, where values remain in fp16 to isolate key effects, from deployment settings such as K3V3, K3V2, and K2V2, where both keys and values are quantized [2606.24033].

The serving path stores mixed-rate key segments and a uniform-rate packed value stream directly in HBM. The paper specifies nibble containers for segments at $\le 4$ bits, byte containers for higher-bit groups, per-segment codebooks, and per-token norms. The fused attention kernel then streams tiles of packed K/V, unpacks the segments, dequantizes through a small fp16 codebook that fits in L1, rescales by per-segment key norms and per-token value norms, computes $QK^\top$ and $PV$ as fp16-input, fp32-accumulate tensor-core GEMMs with a fully fp32 online softmax, and never materializes a full fp16 KV cache in HBM; dequantized tiles are consumed immediately from registers or shared memory [2606.24033].

This systems design turns the mixed-rate allocation into concrete bandwidth and memory savings. At K3V3, the paper reports about $157$ bytes per token per KV head for codes plus norms, compared with $512$ bytes for an fp16 K/V pair, corresponding to approximately $3.24\times$ KV-cache compression in practice. The text attributes the gap from the ideal $5.33\times$ code-only rate to nibble or byte alignment and to per-segment norms and metadata. Calibration is entirely offline and amortized; after warmup, each layer-head allocation is fixed, no fp16 recent-key buffer is required, and a small Q-side rotation from TQ-MSE can be folded into $q\_proj$ weights offline [2606.24033].

## 5. Empirical behavior and benchmark results

The paper evaluates Block-GTQ on a ten-model diagnostic panel and on long-context retrieval, understanding, and reasoning tasks. Under K-only quantization at $2$ and $3$ b/dim, Block-GTQ cuts mean per-layer RoPE-logit MAE by $32$–$80\%$ relative to uniform TQ-MSE and wins all $367/367$ layer comparisons at each budget. Without an fp16 recent-key buffer, it also achieves the lowest mean softmax KL against fp16 and the highest top-10 attended-token overlap at every evaluated budget. The largest gains are reported at higher key budgets, where the allocator can route extra bits to the highest-energy RoPE blocks [2606.24033].

On long-context retrieval and understanding, the reported gains are similarly large. For Llama-3.1-8B-Instruct on the six-task NIAH benchmark, Block-GTQ at K2V2 raises the average from $70.6$ with uniform TQ-MSE to $97.4$, and at K3V3 or K3V2 it remains close to the fp16 ceiling of $99.6$. On LongBench-EN with the same model, the average rises from $36.87$ under uniform TQ-MSE to $53.31$ at K2V2, while Block-GTQ remains closest to fp16 at all listed budgets, with $59.08/58.84/53.31$ at K3V3/K3V2/K2V2 versus $59.83$ for fp16. For Qwen2.5-7B-Instruct on NIAH, the paper reports that uniform TQ-MSE collapses to $0.0$ at all tested budgets, whereas Block-GTQ attains $65.1/64.8/60.1$ at K3V3/K3V2/K2V2 against $67.1$ for fp16 [2606.24033].

The long-reasoning results highlight the same pattern. On AIME 2024/2025 with DeepSeek-R1-Distill-Qwen-7B, and without an fp16 recent-key buffer, Block-GTQ at K3V2 scores $51.7/37.5$, close to fp16’s $54.2/37.9$, while uniform TQ-MSE collapses to $0.0/0.0$. For DeepSeek-R1-Distill-Llama-8B, the corresponding numbers are $32.5/23.3$ for Block-GTQ and $43.3/28.8$ for fp16. The paper notes that PM-KVQ can lead on this backbone through joint K+V layer-wise allocation, which marks a boundary of the present K-focused design [2606.24033].

The systems benchmarks report both efficiency and feasibility gains. On a single H800 GPU with Qwen2.5-3B-Instruct at K3V3, the packed-cache path runs $1.34\times$ faster than fp16 FlashAttention-2 at $128$K context and reduces peak memory from $56.31$ GB to $19.85$ GB. At $256$K and $512$K context, fp16 is reported as OOM, while Block-GTQ remains feasible with peak memory $33.42$ GB and $60.56$ GB. Uniform TQ-MSE is about $14\%$ faster at $128$K and reaches about $3.88\times$ KV compression, but the paper states that its perplexity collapses, whereas Block-GTQ preserves fp16-comparable quality and is therefore the deployable operating point [2606.24033].

## 6. Limitations, comparisons, and scope of the term

Block-GTQ allocates bits only on keys; values use uniform TQ-MSE. The paper explicitly lists this as a limitation, together with the assumption that per-block MSE decays as $4^{-b}$ and the requirement that short calibration capture the typical RoPE energy profile. Distribution shift can perturb the ranking of block sensitivities, especially at very low key budgets. The calibration analysis reports that with $N=2048$ tokens, allocation is stable at K3V3, with block Hamming distances across seeds of approximately $0.07$–$0.09$ and objective regret at most $1\%$–$3\%$, whereas K2V2 is more sensitive and the same ranking noise costs about $4\times$ more in the rate objective. The paper therefore treats a V-side allocator, joint K+V optimization, dynamic per-request allocation, denser packing, and multi-GPU or batched serving for packed caches as future directions [2606.24033].

The method is compared primarily against uniform TQ-MSE and KIVI. Against uniform TQ-MSE, the reported conclusion is consistent across RoPE-logit MAE, attention KL, top-10 attended-token overlap, and downstream long-context tasks. Against KIVI-ScaleOnly, the paper states that per-channel quantization can be competitive when RoPE occupies only half of the key dimensions, as in partial-rotary or MLA settings, because Block-GTQ then has fewer RoPE blocks to differentiate. On fully RoPE’d GQA backbones, the paper reports that Block-GTQ usually wins. A plausible implication is that the method’s advantage is largest precisely when the inference stack exposes a strong RoPE block hierarchy [2606.24033].

The name should not be conflated with unrelated block-based constructions in other areas. The supplied literature also uses block-oriented formulations for quantitative group testing under noiseless, Gaussian, and Z-channel models [2601.11797], for block floating point and scaled block floating point numerical formats [2210.05470], for LDPC-based and spatially coupled quantitative group testing designs [2404.11463], and for block components of generalized quaternion group codes [2501.01502]. Those topics are distinct from the method introduced as “Block-GTQ” in the KV-cache quantization setting.

Source: https://www.emergentmind.com/topics/block-gtq