Add challenge 95: Decode-Phase Attention (Medium)#248
Open
claude[bot] wants to merge 1 commit intomainfrom
Open
Add challenge 95: Decode-Phase Attention (Medium)#248claude[bot] wants to merge 1 commit intomainfrom
claude[bot] wants to merge 1 commit intomainfrom
Conversation
Single-token-query attention over a full KV cache, the dominant kernel in autoregressive LLM decode steps. Supports Grouped Query Attention (GQA) where multiple query heads share one KV head. Teaches the memory-bandwidth- bound nature of decode-phase workloads, distinct from compute-bound training attention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Qhas shape(batch_size, num_q_heads, head_dim)— no sequence dimension — whileKandVare the full KV cache(batch_size, num_kv_heads, cache_len, head_dim)num_q_heads / num_kv_headsquery heads share each KV headbatch_size=4,num_q_heads=32,num_kv_heads=8,cache_len=16,384,head_dim=128Why this is interesting
This challenge teaches a key GPU programming concept: the same attention formula requires a completely different implementation strategy at decode time vs. training time. Training attention (e.g., GQA challenge #80, Flash Attention PR #232) is compute-bound with equal-length Q and KV; decode-phase attention is memory-bandwidth-bound with a single-token query streaming over the entire KV cache. Efficient decode kernels parallelize over batch/heads and reduce over
cache_len, a pattern not covered by any existing challenge or open PR.Test plan
starter.cu,starter.pytorch.py,starter.triton.py,starter.jax.py,starter.cute.py,starter.mojo)pre-commit run --all-filespasses (black, isort, flake8, clang-format, mojo format)run_challenge.py --action submit→ "✓ All tests passed"🤖 Generated with Claude Code