We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Attention Variants
PyTorchAfter Attention 101 — the real-world variants that actually run in modern LLMs.
14 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Cross Attention Practice · Medium
- 2 Not solved yet. Causal Attention Mask Practice · Easy
- 3 Not solved yet. Grouped-Query Attention Practice · Hard
- 4 Not solved yet. Sliding Window Attention Practice · Medium
- 5 Not solved yet. Causal Attention with Framework Operations Practice · Hard
- 6 Not solved yet. KV Cache for Autoregressive Decoding Practice · Hard
- 7 Not solved yet. Attention with Online Softmax Practice · Hard
- 8 Not solved yet. Causal Self-Attention Block Practice · Medium
- 9 Not solved yet. Cross-Attention Block Practice · Medium
- 10 Not solved yet. Causal RoPE and SwiGLU Block Practice · Hard
- 11 Not solved yet. Encoder-Decoder Transformer Forward Pass Practice · Hard
- 12 Not solved yet. Train Encoder-Decoder Seq2Seq Step Practice · Hard
- 13 Not solved yet. Encoder-Decoder Greedy Decode Practice · Medium
- 14 Not solved yet. Encoder-Decoder Beam Search Practice · Hard
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
With the query-head count fixed, what tradeoff does grouped-query attention offer between multi-head and multi-query attention?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
query_heads = 8
for name, kv_heads in [("MHA", 8), ("GQA", 2), ("MQA", 1)]:
print(name, "query heads per KV head:", query_heads // kv_heads)