gqa
Inference interview questions tagged gqa, across every topic.
8 questions · 4 unlocked for you
Concepts behind "gqa"
Concept pages for the mechanisms these questions lean on.
Foundational
The KV Cache: Bytes per Token and the Memory BudgetThe KV cache stores every past token's keys and values so decode never recomputes them. Its size per token is fixed by the attention design, and the memory left after weights and the engine's reserve decides how many sequences fit, which is the number that sets batch size, concurrency and when preemption starts.🧮 KV Cache & Memory
Foundational
Attention With a KV Cache, From ScratchA from-scratch implementation of causal multi-head attention with grouped-query KV heads and a KV cache, in about 35 lines of numpy. Covers the offset causal mask when queries are fewer than keys, why the cache turns quadratic recompute into linear work, and the tests an interviewer runs against it.⌨️ Implementation Patterns
Advanced
Split-KV Decoding (Flash-Decoding)In decode there is one query row per sequence, so a FlashAttention kernel parallelized over batch and heads launches too few thread blocks to pull full HBM bandwidth. Split-KV divides each sequence's keys across blocks and merges the partial results exactly with their log-sum-exp, which decides whether long-context decode reaches bandwidth.🔦 Attention Kernels🔒 Premium