[CuTe] Fix forward dynamic-shape correctness - #2745
Open
drisspg wants to merge 1 commit into
Open
Conversation
drisspg
added a commit
that referenced
this pull request
Jul 29, 2026
Size aliased SM100 K/V shared memory for the larger staged layout so value dimensions wider than query/key cannot write past the allocation. Ceil-divide non-TMA paged loader entries so partial row waves receive page pointers on SM90 and SM100. Add runtime regressions for dense and varlen DV > D, SplitKV, and partial paged tiles across both SM100 loader thread counts. stack-info: PR: #2745, branch: drisspg/stack/59
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 01:15
ac1b7ae to
05b70db
Compare
This was referenced Jul 29, 2026
drisspg
added a commit
that referenced
this pull request
Jul 29, 2026
Size aliased SM100 K/V shared memory for the larger staged layout so value dimensions wider than query/key cannot write past the allocation. Ceil-divide non-TMA paged loader entries so partial row waves receive page pointers on SM90 and SM100. Add runtime regressions for dense and varlen DV > D, SplitKV, and partial paged tiles across both SM100 loader thread counts. stack-info: PR: #2745, branch: drisspg/stack/59
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 02:40
05b70db to
15c9c77
Compare
drisspg
added a commit
that referenced
this pull request
Jul 29, 2026
Size aliased SM100 K/V shared memory for the larger staged layout so value dimensions wider than query/key cannot write past the allocation. Ceil-divide non-TMA paged loader entries so partial row waves receive page pointers on SM90 and SM100. Add runtime regressions for dense and varlen DV > D, SplitKV, and partial paged tiles across both SM100 loader thread counts. stack-info: PR: #2745, branch: drisspg/stack/59
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 03:30
15c9c77 to
b853703
Compare
drisspg
added a commit
that referenced
this pull request
Jul 29, 2026
Size aliased SM100 K/V shared memory for the larger staged layout so value dimensions wider than query/key cannot write past the allocation. Ceil-divide non-TMA paged loader entries so partial row waves receive page pointers on SM90 and SM100. Add runtime regressions for dense and varlen DV > D, SplitKV, and partial paged tiles across both SM100 loader thread counts. stack-info: PR: #2745, branch: drisspg/stack/59
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 06:37
b853703 to
9f2105c
Compare
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 16:41
9f2105c to
baed43c
Compare
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 29, 2026 21:11
baed43c to
9c29874
Compare
drisspg
commented
Jul 30, 2026
drisspg
commented
Jul 30, 2026
drisspg
force-pushed
the
drisspg/stack/59
branch
4 times, most recently
from
July 30, 2026 01:37
af62531 to
8c2e70d
Compare
drisspg
force-pushed
the
drisspg/stack/59
branch
3 times, most recently
from
July 30, 2026 02:48
1567393 to
e997f27
Compare
drisspg
marked this pull request as ready for review
July 30, 2026 03:17
drisspg
marked this pull request as draft
July 30, 2026 03:47
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 30, 2026 03:48
e997f27 to
d1b3abd
Compare
drisspg
marked this pull request as ready for review
July 30, 2026 03:48
drisspg
marked this pull request as draft
July 30, 2026 03:48
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 30, 2026 05:16
d1b3abd to
8c7856c
Compare
Fix forward issues exposed by dynamic-shape and layout fuzzing. Canonicalize unaligned inputs, distinguish static broadcast and auxiliary tensor ABIs in the compile cache, and compile SplitKV combine optional operands exactly as called. Use target-SKU SM metadata during fake selection. Size aliased SM100 K/V shared memory for the larger staged layout and ceil-divide non-TMA paged-loader entries so partial row waves receive page pointers. Add one focused regression for each underlying bug. stack-info: PR: #2745, branch: drisspg/stack/59
drisspg
force-pushed
the
drisspg/stack/59
branch
from
July 30, 2026 16:01
8c7856c to
862b459
Compare
drisspg
marked this pull request as ready for review
July 30, 2026 20:43
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.
Stacked PRs:
Human Note
This is baiscally all small tweaks to our dynamic shape infra; I did a lot of fuzzing of the stack to get a good sense for when recompiles happen and passing in a bunch of configs. These are all the result of that. While I was here I did smallish tweaks to those helpers to remove host overhead where applicable
Agent Note
Summary
This is the small correctness base for the rest of the stack. Dynamic-shape and layout fuzzing found seven pre-existing forward bugs; this PR fixes them without adding configs, tuning APIs, or selector policy.
The cache fixes still keep concrete batch and sequence lengths dynamic.
Host-path cost
The initial fuzz fix was correct but too defensive on the eager hot path. This revision keeps the same cache identities and kernel behavior while removing work unrelated to the seven root bugs:
_flash_attn_fwdhas allocated or validated those tensors;Nightly host microbenchmarks on the same GB300 machine:
These are host-only measurements; no selector policy or generated kernel changed.
For a whole-wrapper check, I used real preallocated CUDA tensors, a warm hit-only compile cache, and a no-op compiled callable. This measures all Python dispatch through the point where the generated kernel would launch, without mixing in GPU execution:
mainDespite adding the correctness checks, this PR is 3.9–4.1 us (23.7–24.2%) faster than
mainon the warm host path because it removes unconditional target-SM discovery, reuses fake-mode state, defers compile-only setup, and uses fast common-layout metadata paths. Real no-graph runs with the actual kernel also showed no latency regression.Review follow-ups
_flash_attn_fwdis forwarded to SplitKV combine, so CPU fake compilation with explicit_archnever probes unavailable hardware.data_ptr()for alignment; FakeTensor retains metadata-only offset checking.__cache_key__remains the regression-test oracle rather than a 9–10 us/tensor runtime conversion.Validation
Focused host tests cover target-SM fallback, CuTe aux-key equivalence, external-base pointer alignment, singleton broadcast-output rejection, and explicit-architecture fake SplitKV. The combine regression now exercises one cache in the order neither optional operand → dynamic splits only → semaphore only → both, checking four specializations and numerical results. The existing unaligned-input test now checks public forward and
dq/dk/dvfor both padded-stride and unaligned-offset views.The targeted GPU regressions pass on GB300/SM103 against independent FP32 references where applicable. Compute Sanitizer previously reported
ERROR SUMMARY: 0 errorsacross the wider q-stage, paged-tail, SplitKV, andDV > Dmatrix. Ruff, formatting,py_compile, andgit diff --checkpass.