Background and Findings
Long-context LLM serving faces a frustrating trade-off on 4-bit tensor cores: uniform 4-bit attention degrades long-range retrieval, while selective FP16 fallback forces systems to keep a full-precision KV cache and leaves decoding unaccelerated. We show that no FP16 backup is needed.
Analyzing why 4-bit retrieval fails reveals two root causes: quantization error concentrates along a few dominant key directions, creating strongly correlated score errors, and retrieval heads operate with narrow score margins where modest 4-bit noise flips the winning key.
ZenMargin Method
ZenMargin resolves both directly in 4-bit precision. It smooths keys with causal centering and a lightweight Hadamard transform, then splits every KV pair into a primary 4-bit tensor and a residual 4-bit tensor under a shared scale (two-limb NVFP4). During prefill, an online margin gate reads only the primary 4-bit limb for 95-99% of blocks and refines the remaining 1-5% of near-peak blocks natively on FP4 tensor cores; during decoding, ZenMargin-Cache reuses the exact same split layout with zero repacking.
Performance and Results
Across six open LLMs on a single RTX 5090 (up to 128K context), ZenMargin is simultaneously fast, compact, and faithful. It reaches 867-967 TFLOPS on real activations (4.0-4.4x FlashAttention-2, 1.5-1.6x SageAttention2++, and faster than FlashInfer NVFP4), holds flat throughput across diffuse and code workloads with zero degradation cliff, and speeds up 64K time-to-first-token by up to 1.9x.
By cutting KV-cache memory 44% below BF16 while reading mostly the primary 4-bit limb, ZenMargin-Cache lifts 32-layer single-GPU serving throughput 2.1-2.9x over FlashInfer BF16, and outperforms FlashInfer FP8, across both long-input and incremental-flush Long-CoT workloads. Without retraining, it matches BF16 accuracy across full 13-task RULER (up to 67.6K) and LongBench.