BMAttn: Block-Aligned Mixed-Precision Attention Quantization for LLM Inference

Zining Wang, Haojie Duanmu, Zhihang Yuan, Fanliu Kong, Ruihao Gong, Jinyang Guo, Xianglong LiuNeurIPS 2026

TL;DR

Processing massive documents with Large Language Models (LLMs) usually hits a computational brick wall because every token wants to pay attention to every other token. BMAttn breaks through this bottleneck by dividing an LLM's attention span into neat, GPU-friendly blocks of 8-bit, 4-bit, and skipped zones—delivering over a 3× attention speedup on long contexts with virtually zero loss in intelligence.

What Problem Does This Paper Address?

Imagine reading a thousand-page mystery novel, and for every new word you read, you pause to re-read every preceding word with intense, equal scrutiny. That is essentially how standard self-attention works in LLMs: its cost scales quadratically ($O(L^2)$) with sequence length $L$.

Existing shortcuts force an awkward compromise. Uniform compression (like quantizing everything to 4-bit, or throwing away tokens outside a fixed window) ignores reality: recent words usually carry delicate grammatical nuances, while distant paragraphs hold broader, fuzzier themes. Conversely, fine-grained adaptivity—picking and choosing precision token-by-token—drives GPUs crazy. GPUs thrive on predictable, assembly-line math; irregular, scattered memory lookups cause "warp divergence" that wipes out theoretical speedups. How do we give important tokens VIP treatment without stalling the GPU assembly line?

Methods

The authors introduce BMAttn (Block-Aligned Mixed-Precision Attention), which marries algorithmic nuance with hardware regularity through four clever ideas:

  • Three-Zone Block-Aligned Partitioning: Instead of a one-size-fits-all bit-width, each attention head's map is split by causal distance into three bands: High-Precision (8-bit) for critical local context (plus initial "attention sink" tokens), Low-Precision (4-bit) for mid-to-long-range context, and Sparse (0-bit / skipped) for negligible distant links. Crucially, these boundaries are snapped onto contiguous hardware tiles (e.g., blocks of 64 or 128), forming a clean staircase pattern that plugs straight into FlashAttention-style GPU loops without warp divergence.
Figure 3: Comparison of different attention window schemes. (a) Window Attention: Fixed-size sliding window. (b) Constant Precision Tiers: High and low precision regions. (c) Affine Window: Adaptive precision boundaries based on context length. (d) Block-Alignment: Attention is divided into contiguous blocks, optimizing hardware efficiency.
  • Affine Windowing: Fixed window sizes calibrated on short texts fail miserably on book-length prompts. BMAttn defines zone boundaries as simple linear equations ($w \cdot L_{\text{ctx}} + b$) of the context length. One quick offline calibration (taking ~75 seconds for a 7B model) lets each head dynamically stretch its attention span at inference time.
  • Inverse-Propensity Weighting (IPW) Calibration: To find those linear parameters offline without losing rare long-range facts, BMAttn reweights raw attention scores by the inverse of their empirical distance probability. This ensures distant tokens get an equal vote during calibration.
Offline saliency calibration using Inverse-Propensity Weighting (IPW) to counteract short-range attention bias.
  • Layer-Adaptive Retention Regularizer: Recognizing that early network layers process fragile lexical details while deeper layers handle redundant, abstract concepts, a linear decay schedule assigns stricter retention budgets to shallow layers ("protect the foundation") and compresses deeper layers more aggressively.

Datasets

  • Calibration: Offline calibration uses 512 samples (at length 2048) from WikiText; ablations also test LongBench, RULER, and Qasper.
  • Evaluation: No new benchmarks are introduced; instead, BMAttn is tested across six established ones covering standard and long-context capabilities: WikiText-2 (perplexity), MMLU (multi-task knowledge), LongBench and InfiniteBench (long-context reasoning), RULER (comprehension across context scales), and NIAH (Needle-in-a-Haystack retrieval).

Key Insights and Ideas

  • The "Sensitivity Gap" Illusion: Standard calibration metrics like Cosine Similarity or MSE are terrible judges of long-context compression. Because attention is heavily concentrated on nearby words, you can chop off 30% of global attention mass, watch Cosine Similarity cheerfully report 99.99% fidelity, and simultaneously watch model perplexity explode! Only IPW-reweighted saliency exposes the loss of rare, distant "needles."
  • Theoretical Uniqueness of IPW: The authors prove mathematically that IPW is the unique distance-based reweighting (up to a constant factor) that guarantees every distance bucket receives uniform protection—turning an intuitive heuristic into a principled bound.
  • Static Windows Collapse at Scale: Calibrating a fixed window at 8k tokens and running it at 128k causes RULER accuracy to crater from 92.39 down to 6.88, whereas BMAttn's affine scaling holds steady at 73.35.
  • Zero "Optimization Tax" on Short Prompts: Dynamic sparse methods often slow down on short sequences due to indexing overhead (e.g., SpargeAttention drops to 0.65× speed at 1k tokens). Because BMAttn simply adjusts loop bounds, it stays faster than baseline across all sequence lengths.

Key Results

Tested across Qwen2.5-7B, Llama3.1-8B, and GLM-4-9B, BMAttn establishes a new efficiency-accuracy Pareto frontier:

Efficiency-accuracy trade-off on Qwen2.5-7B, pushing out the Pareto frontier.
  • Near-Lossless Accuracy: Operating at an average of 5.75 bits, BMAttn stays within 0.5 percentage points of full-precision FlashAttention-2 across all models and benchmarks (even hitting 100.28% normalized average score on Qwen2.5-7B), while handily beating 4-bit SageAttention2 (52.67 vs. 51.70 on LongBench).
  • Kernel & End-to-End Speedups: At 32k context length, BMAttn achieves up to a 3.26× attention-kernel speedup over FlashAttention-2 on Qwen2.5-7B (and up to 4.14× if you tolerate a tiny accuracy dip). In full end-to-end wall-clock generation on an RTX 4090 at 32k tokens, it delivers a 1.33× model-wide speedup, edging out both SageAttention2-4b (1.31×) and SpargeAttention (1.30×).

Limitations and Future Work

Because BMAttn's three-zone staircase is built around causal distance (where tokens only look backward), it doesn't naturally map onto bidirectional encoders or cross-attention mechanisms. For future work, the authors suggest extending the framework to non-causal architectures and stacking BMAttn with orthogonal memory-savers like KV-cache quantization—since speeding up attention math is great, but shrinking the memory footprint of million-token caches is the next frontier.

Summary updated

Abstract

The deployment of Large Language Models (LLMs) with extended context windows is fundamentally constrained by the quadratic computational and memory costs of the self-attention mechanism. While acceleration techniques like sparse attention and quantization offer potential relief, they currently face a critical dilemma: uniform compression strategies fail to capture the non-uniform distribution of information importance, degrading performance on long-range dependencies; conversely, fine-grained, token-level adaptation often introduces irregular memory access patterns that negate theoretical efficiency gains on modern GPUs. To resolve this tension, we introduce BMAttn (Block-Aligned Mixed-Precision Attention), a framework that unifies importance-aware precision allocation with hardware-friendly execution. BMAttn partitions attention maps into block-aligned high-precision, low-precision, and sparse regions, using a novel affine windowing mechanism to dynamically adjust boundaries based on sequence length. We further propose a saliency-weighted calibration method and a layer-adaptive regularizer that adaptively aligns precision targets with perceptual importance and layer sensitivity. Extensive experiments demonstrate that BMAttn achieves a \textbf{3.3x} speedup on long-context tasks with negligible accuracy loss, and up to \textbf{5x} speedup with minimal degradation, effectively bridging the gap between algorithmic adaptivity and hardware efficiency.
BibTeX
@inproceedings{wang2026bmattn,
  author = {Zining Wang and Haojie Duanmu and Zhihang Yuan and Fanliu Kong and Ruihao Gong and Jinyang Guo and Xianglong Liu},
  title = {{BMAttn: Block-Aligned Mixed-Precision Attention Quantization for LLM Inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=VZRJp36FMB},
}
Figure