Co-Designing AI Model Attention for Fast, Interactive Long-Context Inference

AI-generated summary of reporting by NVIDIA Developer Blog. Read the original for the full story.

Why it matters

LLM builders can cut decode latency roughly 2x per doubling of group size by choosing GQA/MQA, head dimensions of 128 or 256, and smaller KV states during model design.

Read this as

NVIDIA engineers published guidance on designing AI model attention, the part of a language model that reads long prompts, so it runs fast on NVIDIA chips. They found that sharing one memory bank among many query heads (a scheme called GQA) makes generating each response token roughly twice as fast for every doubling, while leaving prompt processing unaffected. They also recommend head sizes of 128 or 256, which fit chip hardware neatly. Anyone building or deploying long-context AI models on NVIDIA GPUs benefits.

As context lengths grow, attention consumes most inference time, NVIDIA measured its share of DeepSeek-R1 prefill rising from 18% at 4K context to 85% at 128K. NVIDIA argues these costs are set by model design choices: group size, head dimension, sequence length and tensor parallelism. Teams training their own models on NVIDIA GPUs can roughly halve token-generation time per group-size doubling by following the guidelines; teams serving existing models gain little directly. The analysis appears in TensorRT-LLM tooling.

Prefill is compute-bound (quadratic in ISL); decode is memory-bound on KV cache reads, with arithmetic intensity ≈ 2×G independent of KVSL. Measured FP8 kernels show decode runtime falling ~2x per doubling of G (MHA G=1 to MQA G=64), flattening beyond G=16 at KVSL=32K due to flash-decoding reduction overheads. Hsz of 64 pays for a 128-wide tile and 512 nears TMEM limits, so 128/256 are optimal. Tensor parallelism must not exceed KV head count; few-KV-head models need Wide EP or Helix Parallelism, as in Nemotron 3's GQA with two KV heads.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

FlashAttention TensorRT-LLM Nemotron 3 DeepSeek-R1 GQA MQA Helix Parallelism

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading