Month 4 — FA2 / decode kernels, toy pager, Megatron TP costed, weekly KV numbers
03-kernels/curriculum.md Layer 3 (FA2, paged decode) + Layer 5 start (TP volumes). 04-llm-theory/curriculum.md §D parallelism cheat sheet + §F. Roadmap P1 exit / P2 start.
Month goals
- FA2-style changes in your kernel: parallelize over Q, better occupancy. Still Triton is fine. Backward plan written; implement backward if the forward is solid — do not fake a backward you did not test.
- Decode kernel: seqlen_q = 1 (or small), KV long. Separate from prefill. FlashDecoding idea.
- Toy pager: block table, allocate/free, prefix reuse, fragmentation stat. Not vLLM. A pager.
- Megatron TP drawn and costed: column-parallel + row-parallel, 2× AllReduce (or RS+AG with SP), bytes on the wire for a named MLP.
- KV cache numbers every week (same config, growing intuition): 70B-class GQA, vary seq and batch and dtype.
Take-home: hold < 2,000 and hunt the next 1.2×. Do not stall the kernels to chase 1487 this month.
Week 13 — FA2 algorithm into the kernel
| Day | Deep 1 | Deep 2 | Paper / book | Fri / Sat |
|---|---|---|---|---|
| Mon | FA2 paper: the three changes vs FA1. Patch your Triton loop. | Work/span of the new parallelization. | Dao 2023 FA2. | |
| Tue | Causal load-imbalance. Measure. | Decode-shaped kernel v0 (q=1). | FlashDecoding. | |
| Wed | Debug day. | Take-home. | None. | |
| Thu | KV numbers (week 13): 80L, 8 kv heads, d=128, S=8k, B=16, fp16. Then S=128k. Then fp8. Write GB. | Interview whiteboard 25 min: same calculation cold. | None. | |
| Fri | Take-home sport. | |||
| Sat | Long build: FA2 vs FA1 speed table on your GPU. Honest. | |||
| Sun | Off-ish. |
Week 14 — Toy pager
| Day | Deep 1 | Deep 2 | Paper / book | Fri / Sat |
|---|---|---|---|---|
| Mon | Kwon et al. 2023 PagedAttention. Draw logical→physical block table. | Python pager: pages of tokens, alloc/free, refcount. | vLLM paper. | |
| Tue | Decode attention that gathers via block table (03-kernels L3 ex. 8 energy, even if CPU/numpy first). | Copy-on-write for a beam of 2. | None. | |
| Wed | Debug pager fragmentation under a synthetic trace. | Take-home. | None. | |
| Thu | KV numbers (week 14): same model, paged with block=16 vs 128. Internal fragmentation. | System-design 45 min: "one GPU, variable-length decode, design the batcher." Record. | Orca abstract only (full read month 6). | |
| Fri | Take-home. | |||
| Sat | Long build: pager + decode demo in the public repo. | |||
| Sun | Off-ish. |
Week 14 exit: a pager you can explain, not a vLLM clone.
Week 15 — Megatron TP drawn and costed
| Day | Deep 1 | Deep 2 | Paper / book | Fri / Sat |
|---|---|---|---|---|
| Mon | Shoeybi 2019 + Narayanan 2021 enough to draw TP for one Llama-style MLP. | Bytes: AllReduce volume vs RS+AG. | Megatron 2019. | |
| Tue | Implement ColumnParallel + RowParallel in PyTorch (1–2 GPU if you have them; else simulate ranks). | Match single-GPU Linear numerically. | Korthikanti 2022 SP (why SP rides along). | |
| Wed | Debug comm vs math. | Take-home. | None. | |
| Thu | KV numbers (week 15): TP=2, what shards, what is not sharded (KV often replicated per TP rank — write it). | Cost a 70B, seq 8k, global batch, pick TP/PP/DP on paper (04-llm-theory §D whiteboard). | ZeRO paper enough to say why ZeRO-3 ≠ TP. | |
| Fri | Take-home. | |||
| Sat | Long build: one-page "TP for this block" diagram + comm table. | |||
| Sun | Off-ish. |
Week 16 — Close month 4
| Day | Deep 1 | Deep 2 | Paper / book | Fri / Sat |
|---|---|---|---|---|
| Mon | FA2 backward plan or tiny backward on S=64. Honesty rule: untested backward = not done. | Pager polish. | None. | |
| Tue | Decode vs prefill roofline on one plot. | Interview drill 90 min. | None. | |
| Wed | Debug / measure. | Take-home. | None. | |
| Thu | KV numbers (week 16): pick a new config (MLA from DeepSeek-V2 §2.1 bytes/token vs GQA-8). | Blank-page TP diagram. | DeepSeek-V2 MLA section only. | |
| Fri | Take-home. Hold < 2,000. | |||
| Sat | Month 4 artifact. | |||
| Sun | Off. |
Month 4 exit criteria
Artifact
pager/ + tp-notes.md + FA2 table + notes/kv/week-13..16.md + 1000-word writeup. This is the first month that looks like the Inference Systems req.