perf(sm100): async-stage incomplete packed-varlen tiles - #44
Open
SakiNana7qi wants to merge 3 commits into
Open
Conversation
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.
Fixes #43.
Summary
cp.async, so a tail never reads into the following sequence.prepare_h: K and V/A use separate producer warps for incomplete tails, while complete tiles retain TMA.The prior guarded elementwise tail loops made every short sequence pay a serialized staging cost. This change preserves the existing CTA shape, chunk size, tensor layouts, and complete-tile data path; it only changes how the final incomplete tile reaches shared memory.
B200 benchmark
Packed varlen,
Hq=Hk=Hv=12, head dimension 128, BF16 Q/K/V, FP32 decay, TileLang 0.1.9. Times are CUDA-event medians from four balanced AB/BA rounds; backward is incremental backward latency.For the issue workload (
N=4096,L=32):mainThe real-L32 path improves by 3.80x in forward, 1.71x in backward, and 2.24x for the combined operator.
The boundary sweep uses
L = {1, 2, 4, 8, 16, 24, 31, 32, 33, 40, 48, 56, 63, 64, 65, 127, 128, 129, 255, 256, 257, 511, 512, 513, 1023, 1024, 1025, 2047, 2048, 2049}with
N = min(4096, floor(131072 / L)). Each checkout uses an independent TileLang cache; checkout order and length order are reversed symmetrically across the four rounds.Exact full-tile points remain at main-level training latency:
Across these six full-tile points, combined latency changes by
-0.60%to+0.47%(median-0.33%). Across all 30 points, the range is-67.72%to+0.99%; the largest positive observation is the nearly full-tileL=2049case. The remaining sub-1% deltas are shown rather than hidden behind an acceptance threshold.For tails immediately below successive 64-row multiples, combined latency improves by 67.72% (
L=63), 59.53% (L=127), 48.14% (L=255), 35.73% (L=511), 23.18% (L=1023), and 13.39% (L=2047).Validation
mainand 4 rounds on a clean PR checkout, with 30 cases per worker.mainand this PR.N=256; a deterministic 1,048,576-element sample coversN=4096.All metrics are reported as observations; no precision or performance threshold gates are used.
Implementation notes
cp.asyncsplit is intentional: complete tiles are safe and faster with TMA; only an incomplete packed-varlen tile needs per-row predication and zero fill. Comments state this decision next to both paths.prepare_h, the K-producer warp loads K/V/A with TMA for complete tiles, while the V/A-producer warp owns only incomplete V/A tails; the branches and comments make that ownership explicit.WARP_SIZEandCONSUMER_WARP_COUNT; the warp layout is documented at the start of each JIT factory.has_incomplete_tileis a JIT specialization argument derived from the existing chunk metadata. Pure full-tile batches do not execute or generate the larger async-tail body, and this adds no device synchronization.