B200 GEMM Optimization Ladder
R — Source evidence (Reading, paraphrased)
- [S11] Start from a minimal correct single tile, then add K accumulation and multi-CTA spatial tiling one step at a time, avoiding debugging all the complexity at once.
- [S12] First let TMA take over the regular tile copies, then use multi-stage SMEM and a persistent scheduler to reduce waiting.
- [S13] Warp specialization assigns load, MMA, and writeback to different roles; 2-CTA cluster and multi-consumer further remove serial bottlenecks.
- [S3] Every level should be driven by roofline and measured evidence; a more complex structure is not guaranteed to be faster.
Source: distilled from "Modern GPU Programming for MLSys" (https://mlc.ai/modern-gpu-programming-for-mlsys/) and the NVIDIA Blackwell tuning/compatibility guides. Short paraphrases only; no long passages are reproduced.
I — Methodology skeleton (Interpretation)
GEMM optimization is not generating the "final kernel" in one shot, but a regression-testable, bisectable upgrade path. Every level must simultaneously satisfy:
- correct against the reference;
- an explainable layout/synchronization contract;
- the performance change is measured;
- if it regresses, you know where the added resource or serialization point is.
The agent should keep the version at every level; jumping straight to a complex warp-specialized cluster kernel and then blindly guessing at bugs is forbidden.
A1 — Applications in the source (Past Application)
The nine-level route in the book
- A single 128×128 output tile.
- K-loop accumulation.
- Multiple CTAs covering the full M/N.
- TMA async load/store.
- PIPE_DEPTH=2 software pipeline.
- Persistent kernel + tile scheduler.
- Warp specialization.
- 2-CTA cluster.
- Multi-consumer warp specialization.
Every level keeps the same basic data path: GMEM→SMEM→tcgen05→TMEM→register/SMEM→GMEM, changing only concurrency and scheduling.
A2 — Trigger scenarios (Future Trigger) ★
In what situations will the user need this skill?
- "Start from a correct GEMM and optimize it step by step into a high-performance B200 version."
- "My GEMM is at Step 5 now; should the next step be persistent or warp specialization?"
- "Write correctness and performance acceptance criteria for each level."
Language signals
- "Start from a correct GEMM and optimize it step by step into a high-performance B200 version."
- "My GEMM is at Step 5 now; should the next step be persistent or warp specialization?"
- "Write correctness and performance acceptance criteria for each level."
Distinction from adjacent skills
Difference from b200-kernel-roofline-triage: this skill is the GEMM-specific implementation route; the roofline skill decides whether compute/overlap optimization should continue to be pursued. Combine with the individual specialized skills to complete the concrete stages.
E — Executable steps (Execution)
Once the skill is activated, the agent must execute the following process:
- Establish the baseline contract
- Fix the math definition, layout, dtype, reference, timing framework, and representative shape set.
- Level 1: single-tile correct path
- Synchronous copy, one MMA, TMEM readback, store.
- Acceptance: element-wise correct on small matrices, with every address space explainable.
- Level 2: K-loop
- Correctly handle the initial accumulator, per-K-tile accumulation, and the K tail.
- Level 3: spatial tiling
- grid→M/N tile mapping, boundary masks, full matrix coverage.
- Level 4: TMA
- descriptor/swizzle, load barrier, store drain; compare against the synchronous version bitwise/within tolerance.
- Level 5: multi-stage pipeline
- prologue/steady/epilogue, stage/phase ledger; measure the actual overlap.
- Level 6: persistent scheduler
- A fixed set of resident CTAs processes multiple tiles; check the tail and tile order.
- Level 7: warp specialization
- producer/MMA/writeback roles, the four classes of handoff, warpgroup-scoped sync.
- Level 8: 2-CTA cluster
- cluster tile, DSMEM/multicast, cta_group::2, remote barrier.
- Level 9: multi-consumer
- Multiple consumers partition the N/M/output regions, ensuring the same staged operand feeds more compute without write conflicts.
- Per-level gating
- Correctness: random shapes, misalignment, K=1/multi-tile, NaN/Inf, error thresholds.
- Performance: compare against the previous level, the library baseline, and the roofline.
- Resource: register/SMEM/TMEM, active clusters, spill.
- Stopping rule
- If you are already close to the practical roofline or added complexity no longer brings stable gains, stop upgrading and keep the simpler version.
Required outputs
- Conclusion: the current choice/diagnosis; do not use a vague "it could be any of them".
- Evidence or assumptions: which items come from user data, and which are hypotheses awaiting verification.
- Contract/table/timeline: the auditable intermediate artifacts corresponding to this skill.
- Minimal validation: correctness tests, boundary tests, and one falsifiable experiment.
- Risks and fallback: alternative paths when hardware, version, or resource requirements are not met.
B — Boundaries (Boundary) ★
Do not use when
- cuBLASLt/CUTLASS already meets the need and there is no fusion, special dtype/layout, or research purpose.
- There is no correctness reference or reliable timing framework.
Failure modes
- Jumping multiple levels at once, making the source of an error impossible to localize.
- Testing only one neat large shape, ignoring small shapes and tail tiles.
- Treating warp specialization as a guaranteed speedup, ignoring the occupancy of the added roles and the sync.
Limitations
- The book's route is based mainly on TIRx and specific example shapes; when porting to CUDA/CUTLASS/Triton, keep the principles rather than copying the APIs verbatim.
Related skills
- depends-on:
b200-kernel-roofline-triage, b200-scope-layout-dispatch
- contrasts-with: none
- composes-with:
b200-tma-pipeline-designer, b200-mbarrier-protocol-auditor, b200-tcgen05-mma-contract-builder, b200-cluster-persistent-scheduler, b200-warp-specialized-debugger
Audit info
- Validation passed: V1 ✓ / V2 ✓ / V3 ✓
- Test definitions: 6 (3 should_trigger / 2 should_not_trigger / 1 edge_case)
- Hardware validation: not performed; must be verified on a target B200
- Distilled: 2026-06-25
1---2name: b200-gemm-optimization-ladder3description: Use when the user wants to implement from scratch, port, or systematically optimize a B200/Blackwell GEMM. Advances level by level along "correct single tile→K loop→spatial tiling→TMA→multi-stage pipeline→persistent→warp specialization→2-CTA cluster→multi-consumer", with a correctness and performance gate at every level. Not for cases that only want to call a mature BLAS and need no custom fusion/layout.4---56<!-- Distilled from "Modern GPU Programming for MLSys" — https://mlc.ai/modern-gpu-programming-for-mlsys/ -->78# B200 GEMM Optimization Ladder910## R — Source evidence (Reading, paraphrased)1112- [S11] Start from a minimal correct single tile, then add K accumulation and multi-CTA spatial tiling one step at a time, avoiding debugging all the complexity at once.13- [S12] First let TMA take over the regular tile copies, then use multi-stage SMEM and a persistent scheduler to reduce waiting.14- [S13] Warp specialization assigns load, MMA, and writeback to different roles; 2-CTA cluster and multi-consumer further remove serial bottlenecks.15- [S3] Every level should be driven by roofline and measured evidence; a more complex structure is not guaranteed to be faster.1617> Source: distilled from "Modern GPU Programming for MLSys" (https://mlc.ai/modern-gpu-programming-for-mlsys/) and the NVIDIA Blackwell tuning/compatibility guides. Short paraphrases only; no long passages are reproduced.1819---2021## I — Methodology skeleton (Interpretation)2223GEMM optimization is not generating the "final kernel" in one shot, but a regression-testable, bisectable upgrade path. Every level must simultaneously satisfy:2425- correct against the reference;26- an explainable layout/synchronization contract;27- the performance change is measured;28- if it regresses, you know where the added resource or serialization point is.2930The agent should keep the version at every level; jumping straight to a complex warp-specialized cluster kernel and then blindly guessing at bugs is forbidden.3132---3334## A1 — Applications in the source (Past Application)3536### The nine-level route in the book371. A single 128×128 output tile.382. K-loop accumulation.393. Multiple CTAs covering the full M/N.404. TMA async load/store.415. PIPE_DEPTH=2 software pipeline.426. Persistent kernel + tile scheduler.437. Warp specialization.448. 2-CTA cluster.459. Multi-consumer warp specialization.4647Every level keeps the same basic data path: GMEM→SMEM→`tcgen05`→TMEM→register/SMEM→GMEM, changing only concurrency and scheduling.4849---5051## A2 — Trigger scenarios (Future Trigger) ★5253### In what situations will the user need this skill?54551. "Start from a correct GEMM and optimize it step by step into a high-performance B200 version."562. "My GEMM is at Step 5 now; should the next step be persistent or warp specialization?"573. "Write correctness and performance acceptance criteria for each level."5859### Language signals6061- "Start from a correct GEMM and optimize it step by step into a high-performance B200 version."62- "My GEMM is at Step 5 now; should the next step be persistent or warp specialization?"63- "Write correctness and performance acceptance criteria for each level."6465### Distinction from adjacent skills6667Difference from `b200-kernel-roofline-triage`: this skill is the GEMM-specific implementation route; the roofline skill decides whether compute/overlap optimization should continue to be pursued. Combine with the individual specialized skills to complete the concrete stages.6869---7071## E — Executable steps (Execution)7273Once the skill is activated, the agent must execute the following process:74751. **Establish the baseline contract**76 - Fix the math definition, layout, dtype, reference, timing framework, and representative shape set.772. **Level 1: single-tile correct path**78 - Synchronous copy, one MMA, TMEM readback, store.79 - Acceptance: element-wise correct on small matrices, with every address space explainable.803. **Level 2: K-loop**81 - Correctly handle the initial accumulator, per-K-tile accumulation, and the K tail.824. **Level 3: spatial tiling**83 - grid→M/N tile mapping, boundary masks, full matrix coverage.845. **Level 4: TMA**85 - descriptor/swizzle, load barrier, store drain; compare against the synchronous version bitwise/within tolerance.866. **Level 5: multi-stage pipeline**87 - prologue/steady/epilogue, stage/phase ledger; measure the actual overlap.887. **Level 6: persistent scheduler**89 - A fixed set of resident CTAs processes multiple tiles; check the tail and tile order.908. **Level 7: warp specialization**91 - producer/MMA/writeback roles, the four classes of handoff, warpgroup-scoped sync.929. **Level 8: 2-CTA cluster**93 - cluster tile, DSMEM/multicast, cta_group::2, remote barrier.9410. **Level 9: multi-consumer**95 - Multiple consumers partition the N/M/output regions, ensuring the same staged operand feeds more compute without write conflicts.9611. **Per-level gating**97 - Correctness: random shapes, misalignment, K=1/multi-tile, NaN/Inf, error thresholds.98 - Performance: compare against the previous level, the library baseline, and the roofline.99 - Resource: register/SMEM/TMEM, active clusters, spill.10012. **Stopping rule**101 - If you are already close to the practical roofline or added complexity no longer brings stable gains, stop upgrading and keep the simpler version.102103### Required outputs1041051. **Conclusion**: the current choice/diagnosis; do not use a vague "it could be any of them".1062. **Evidence or assumptions**: which items come from user data, and which are hypotheses awaiting verification.1073. **Contract/table/timeline**: the auditable intermediate artifacts corresponding to this skill.1084. **Minimal validation**: correctness tests, boundary tests, and one falsifiable experiment.1095. **Risks and fallback**: alternative paths when hardware, version, or resource requirements are not met.110111---112113## B — Boundaries (Boundary) ★114115### Do not use when116- cuBLASLt/CUTLASS already meets the need and there is no fusion, special dtype/layout, or research purpose.117- There is no correctness reference or reliable timing framework.118119### Failure modes120- Jumping multiple levels at once, making the source of an error impossible to localize.121- Testing only one neat large shape, ignoring small shapes and tail tiles.122- Treating warp specialization as a guaranteed speedup, ignoring the occupancy of the added roles and the sync.123124### Limitations125- The book's route is based mainly on TIRx and specific example shapes; when porting to CUDA/CUTLASS/Triton, keep the principles rather than copying the APIs verbatim.126127---128129## Related skills130131- **depends-on**: `b200-kernel-roofline-triage`, `b200-scope-layout-dispatch`132- **contrasts-with**: none133- **composes-with**: `b200-tma-pipeline-designer`, `b200-mbarrier-protocol-auditor`, `b200-tcgen05-mma-contract-builder`, `b200-cluster-persistent-scheduler`, `b200-warp-specialized-debugger`134135---136137## Audit info138139- **Validation passed**: V1 ✓ / V2 ✓ / V3 ✓140- **Test definitions**: 6 (3 should_trigger / 2 should_not_trigger / 1 edge_case)141- **Hardware validation**: not performed; must be verified on a target B200142- **Distilled**: 2026-06-25