feat(kda): add bitwise-aligned SM100 CuTeDSL forward - #123
Conversation
1fa3215 to
f658595
Compare
Signed-off-by: shuyan.ycf <shuyan.ycf@antgroup.com>
f658595 to
f57238f
Compare
| """Benchmark/profiling entry for SM100 KDA K123 inverse variants. | ||
|
|
||
| Examples: | ||
| python benchmarks/bench_kda_fwd_intra_sm100_fused_inv.py --mode both |
There was a problem hiding this comment.
typo: should be benchmarks/bench_kda_sm100_intra_fused.py
Does the acceleration come from fusing gate activation + cumsum into chunk_fwd_intra, or just the CuTeDSL speedup? |
Gate activation and chunk cumsum are deliberately outside this correctness boundary. The gain therefore comes from the CuTeDSL implementation and scheduling, especially the persistent recompute-W/U pipeline, vectorized KG stores, and removal of unnecessary launch/scheduling overhead. Standalone recompute-W/U alone is about 4.2% faster. |
Description
This PR adds an SM100 CuTeDSL implementation of the KDA forward intra and recompute-W/U path.
The review boundary is a one-to-one port of the csrc API that consumes the same precomputed FP32
gktensor. It preserves the csrc TF32/FP32 arithmetic order, including the single-accumulator K=32 Schur product, and is bitwise equal to csrc for the complete Aqk, Akk, KG, W, and U tensors.Included components:
The existing public csrc dispatch remains unchanged. The CuTeDSL specialization is currently limited to SM100, K=V=128, and chunk size 64.
Correctness
Tested on NVIDIA GB200 (SM100):
Results:
torch.equal, without numerical tolerance;Bitwise results at the representative
B=2,T=8192,H=64,K=V=128shape:torch.equalPerformance
Complete csrc-boundary intra, Akk inverse, and recompute-W/U on the same precomputed FP32
gkinput, with three warmup iterations and 20 CUDA-Event-timed iterations:The standalone recompute-W/U path at the same representative T=8192 shape measures 0.3261 ms for csrc and 0.3129 ms for CuTeDSL, or 1.042x csrc throughput.
Appendix: 10,000,000-replay determinism and csrc alignment
The stress harness first requires complete bitwise equality with csrc, then captures CuTeDSL intra, Akk inverse, recompute-W/U, and a comparison of every Aqk/Akk/KG/W/U element against the csrc outputs in one CUDA Graph. Every replay therefore validates the full output, not a checksum or sample.
Stress configuration and result:
B=1,T=256,H=4,K=V=128, BF16 beta;Before replay, Aqk, Akk, KG, W, and U each had zero mismatched elements and zero maximum absolute difference from csrc. FP32 beta is covered by the strict pytest suite; this long replay uses the representative BF16 beta specialization.
Reviewer notes
fp32_akk_inv=Trueis required by the csrc-boundary API. The experimental in-CTA inverse is rejected rather than being included in the bitwise claim.docs/kda_sm100_cutedsl_fwd_status.md.Checklist
pre-commit run --all-files