A Fused Runtime Sanitizer for Low-Bit Language Models

Quantized language models, whose weights and activations are stored as 4-bit or smaller integers instead of 16-bit floats, fail unevenly. On most inputs a 4-bit model tracks the full-precision model closely. On some tokens, such as a rare activation spike or a step deep in a math derivation, the rounding error grows large enough to change the next-token distribution, and nothing at serving time reports it. This proposal applies an idea from dynamic program analysis to quantized inference: monitor every execution, flag the moments where quantization is likely to have gone wrong, and recompute only those moments at higher precision. Dynamic analysis tools usually cost 2× to over 200× in slowdown. We avoid that cost by computing the monitoring signal inside the GPU kernel that already holds the activations in registers, which is where kernel fusion comes in. The monitor then costs a few extra multiply-adds per element and no extra trips to memory.

Put plainly, the fused normalize-and-quantize kernel also computes a cheap estimate of how much error this token's quantization will add to the next layer's output. Tokens whose estimate crosses a threshold go to a slow path with higher-precision activations. If the estimate predicts real downstream damage, a W4A4 model (4-bit weights, 4-bit activations) with a small fallback rate should match W4A8 quality at close to W4A4 speed.

Core Claim

Quantization-induced accuracy loss is currently treated as a static property. It is minimized offline with rotations (QuIP), data-aware transforms (WUSH) or channel reassembly (QLLM), then measured as an average perplexity. We claim that much of the remaining loss comes from a small, input-dependent fraction of tokens and layers. We further claim these can be detected per token, before the matrix multiply, from quantities the fused kernel already has.

For a linear layer with weights $W$, let $\Delta W = W - Q(W)$ be the weight quantization error and $e = x - Q(x)$ the activation rounding error for input row $x$. Let $d_j = \lVert \Delta W_{:,j} \rVert^2$ and $w_j = \lVert W_{:,j} \rVert^2$ be per-input-channel column energies, precomputed once. The detector score is

$$ s(x) = \sum_j \left( x_j^2\, d_j + e_j^2\, w_j \right), $$

which estimates the squared output error $\lVert Q(W)Q(x) - Wx \rVert^2$. The estimate holds when errors in different columns are roughly uncorrelated. Incoherence processing of the kind QuIP introduced is designed to make that approximately true, so the score is most trustworthy exactly in the rotated setting where modern low-bit methods operate.

Computing $s(x)$ needs two fused multiply-adds per element plus one row reduction. Both happen while $x$ and $e$ sit in registers during the fused normalization-plus-quantization step, so the monitor adds no global-memory traffic.

What would be new is not a better quantizer. It is a runtime check with bounded overhead that turns a quantizer's worst cases into selective recomputation. The closest existing work, WUSH and QLLM, fuses outlier handling into kernels, but its transforms are fixed at calibration time and nothing observes whether a given live token was handled well.

Research Program

The work borrows three ideas from dynamic analysis.

Fast path and slow path. The Taint Rabbit cut generic taint tracking from 237× to 1.7× overhead by compiling specialized fast paths for common states and falling back to general handlers for rare ones. Our fast path is the standard fused W4A4 GEMM (general matrix multiply) with the score computed in its prologue. Flagged token rows are compacted into a side buffer by an atomic append that happens inside the kernel. A second grouped GEMM then recomputes those rows with 8-bit activations against the same 4-bit weights and overwrites the fast-path outputs. Because flagged rows are batched together, the slow path runs as a dense small GEMM rather than as divergent per-token branches. This matters because irregular outlier indexing is a known cost of outlier-preserving schemes such as AdpQ.

Frequency-sensitive policy. FRESA cut race-detection slowdown from about 10× to under 3× by sampling frequently accessed locations less, since their behavior is predictable. By analogy, layers that are flagged very often are not dynamic hazards but statically under-provisioned. Once their flag rate exceeds a budget, we promote them permanently to higher precision and stop monitoring them. Layers that are almost never flagged get sampled monitoring. The per-layer threshold is set by a single global fallback budget, tuned once on calibration text.

Overhead accounting. Following the dynamic-analysis literature, we report the monitor as a slowdown factor over the unmonitored kernel. We report fused and unfused versions separately, so the contribution of fusion is measured rather than assumed.

The engineering plan builds on the fused normalization pattern of TurboTransformers. The score reduction will reuse the per-row statistics that RMSNorm already computes; CoupledNorm shows these statistics can be shared rather than recomputed. Kernels are written in Triton, and block sizes are tuned under a register-pressure constraint, because the extra accumulators are the main risk to occupancy. We extend the same score to 2-bit KV caches, where attention keys and values are stored compressed. There, the flagged tokens are stored at 4 bits.

This replaces the static saliency heuristics of AKVQ-VL with measured per-token error. AKVQ-VL assigns precision by fixed rules: early layers treat text tokens as salient, later layers treat fixed pivot tokens as salient. Our score measures error directly for each token instead.

Two prior results shape the design. Cheng et al. show that re-normalizing layer statistics cannot recover low-bit accuracy. That rules out a cheaper design in which the monitor merely rescales flagged tokens, which is why the slow path recomputes. Huang et al. find that low-bit models lose reasoning ability before fluency. This is our motivation: average perplexity hides silent failures that per-token monitoring could catch, so reasoning benchmarks carry the evaluation.

Baselines

Naive reference point. Hadamard-rotated W4A4 with dynamic per-token activation scales and round-to-nearest (RTN) rounding, no monitoring. This fixes the speed ceiling and the quality floor.

Strongest existing quality method. WUSH, which learns data-aware blockwise transforms fused into a CUTLASS quantization kernel. It reports +2.8 average points over Hadamard RTN and +0.7 over GPTQ on LLaMA-3.1-8B-Instruct at MXFP4 W4A4, recovering over 98% of BF16 accuracy on MMLU-CoT and GSM8K. We run WUSH with its own calibration recipe on FineWeb-Edu, on the same model and the same GPU. The comparison that counts is at matched measured throughput. Beating WUSH means either closing most of its remaining gap to BF16 on GSM8K at no more than 5% lower throughput, or matching its accuracy while running on a cheaper base quantizer. Because the sanitizer can sit on top of WUSH, we also report WUSH plus sanitizer. That combination is the configuration that most directly tests whether monitoring adds value beyond the best static transform.

Second strong competitor. QLLM, which reports outperforming OmniQuant by 7.89% on average across five zero-shot tasks for W4A4 LLaMA-2-70B. It also reports a 4% latency overhead from reassembly that could not be fused. It is the most direct representative of adaptive outlier handling built into the kernel.

Quality upper bound. Static W4A8 everywhere. Our target is at least 80% of the W4A4-to-W4A8 quality gap recovered at a fallback rate under 5% of tokens.

Ablations. Four ablations isolate the key ingredients. Random fallback at the same rate isolates the score's predictive value. Flag-and-promote using only activation clipping counts, without the $d_j, w_j$ weighting, isolates the weighted error estimate. An unfused monitor that runs the score as a separate reduction kernel isolates what fusion buys. Disabling the frequency-based layer promotion isolates the FRESA-style policy.

All methods share the same calibration data budget, the same models, and the same tuning budget for block sizes. We give each baseline equal autotuning time on the same hardware.

Why not just…?

Why not just use dynamic per-token activation scales, which already adapt to outliers? Per-token scaling adapts the quantization range to each token but not its resolution. A token with one huge channel still crushes its other channels into a few bins. Per-token scaling also does nothing about the weight-error term $x_j^2 d_j$, which dominates when a token places energy on badly quantized columns. It is our naive baseline, so the random-versus-scored fallback comparison on top of it answers this question directly.

Why not just use a better static quantizer at slightly more bits? This is the real threat. If WUSH at a uniform format already reaches BF16 quality on the tasks that matter, a per-token fallback has nothing left to fix. The experiments settle it through the WUSH plus sanitizer arm and a Pareto plot of accuracy against measured tokens per second. If the sanitizer only helps weak quantizers, we will report that its value is as a cheap substitute for calibration-heavy transforms. That would matter for calibration-free settings of the kind AlphaQ and AdpQ argue for, but it would be a narrower claim.

Why not just monitor the output, for example flagging high-entropy next-token distributions and regenerating them? Output entropy is cheap and needs no kernel work. However, it detects uncertainty, not quantization damage: a confidently wrong reasoning step has low entropy, which is exactly the failure Huang et al. describe. Regenerating after the fact also recomputes the whole forward pass rather than one layer's rows. We include an entropy-triggered full-precision regeneration baseline at matched compute. If it matches our per-token KL detection quality, the fusion machinery is unjustified.

Why not just run the monitor as a separate, unfused kernel? It might be cheap enough. The unfused ablation measures this directly. We expect its cost to be an extra read of every activation per layer, which is significant in memory-bound decoding. If the measured difference is under 2%, we will say fusion is unnecessary.

Proposed Experiments

Models and settings. LLaMA-2-7B, LLaMA-2-70B and LLaMA-3.1-8B-Instruct at W4A4 and W3A4, plus 2-bit KV cache on LLaVA-v1.5-7B.

Benchmarks. WikiText2 and C4 perplexity; the zero-shot commonsense suite (PIQA, ARC, HellaSwag, WinoGrande, BoolQ); GSM8K and MMLU-CoT for reasoning; MileBench for the KV-cache variant. For the KV setting, AKVQ-VL reports near-lossless 2-bit quantization with a 2.46× throughput gain on LLaVA-v1.5-7B, and that is the bar.

Systems metrics. Decode and prefill tokens per second, the slowdown factor of the monitor over the unmonitored fused kernel, register count and occupancy, and slow-path fraction per layer.

First decisive check: does the score predict damage? This check comes before any throughput work. For every token and layer on held-out text, we compute the true per-token KL divergence between the quantized and FP16 next-token distributions. We then measure the area under the ROC curve for predicting tokens in the top 1% of KL, comparing $s(x)$ against clipping count, activation max-to-scale ratio, and random selection. If the score's area under the curve is not clearly above the clipping-count baseline, the weighted estimate adds nothing, and the design collapses to a simpler outlier trigger.

Second decisive check: does the fused monitor stay under 3% slowdown with less than a 10% occupancy drop? If it does not, the dynamic-analysis argument fails at the point it most needs to hold.

Third decisive check: GSM8K at matched throughput. Reasoning is where static averages are expected to hide the most damage. If W4A4 plus sanitizer does not beat WUSH on GSM8K at equal throughput, and WUSH plus sanitizer does not beat WUSH alone, we will conclude that per-token quantization failures are too rare, or too diffuse, to be worth catching at runtime.