Skip to content

[FA4] Keep stream last in the SM100 MLA kernel so disk-cached objects load - #42926

Merged
nvpohanh merged 3 commits into
sgl-project:mainfrom
nvpohanh:claude/ci-fix-fa4-mla-stream-last
Oct 7, 2026
Merged

nvpohanh merged 3 commits into
sgl-project:mainfrom
nvpohanh:claude/ci-fix-fa4-mla-stream-last

Conversation

@nvpohanh

@nvpohanh nvpohanh commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

[by Claude Code]

Fixes #42925

Motivation

Since #42239 merged, test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py fails on the B200 PR Test Base job (base-b-test-4-gpu-b200 (0)) with:

TypeError: Expects 18 parameters when calling: `__call__(mQ, mQv, mK, mV, mO, mLSE, softmax_scale, mP, mRowMax, mCuSeqlensQ, mCuSeqlensK, mSeqUsedQ, mSeqUsedK, mIndexTopk, mPageTable, window_size_left, window_size_right, mValue)`

#42239 added mValue to FlashAttentionMLAForwardSm100.__call__ as a keyword-only parameter after stream. The MLA (qv) path in interface.py calls the kernel with 17 positional arguments. A freshly compiled kernel accepts that, but the persistent CuTe JIT cache exports the kernel to disk. When a later process reloads it, the loaded TVM-FFI function requires every parameter before the implicit stream, so the call fails. The first process on a runner passes (which is why #42239's own CI passed), and later ones fail. See #42925 for the failing jobs.

Modifications

  • flash_fwd_mla_sm100.py: move mValue before stream so that stream stays the last parameter.
  • flash_attn/cute/interface.py: pass None for mValue explicitly at the qv compile and call sites. Only FlashAttentionMLAForwardSm100 uses this branch (qv is asserted Blackwell-only).

forward_gqa (#42239's GQA-512 path) passes mValue and stream by keyword, so it is unaffected.

Accuracy Tests

Tested on a B200 (CuTe DSL 4.8.0, tvm-ffi 0.1.11, the same versions as CI). Each check runs as two processes against one fresh SGLANG_CUTE_AOT_CACHE_DIR, so process 2 loads the object that process 1 exported.

Check main 2889158792 (process 1 / process 2) this PR (process 1 / process 2)
FA4 MLA prefill: flash_attn_with_kvcache(q=q_rope, qv=q_nope, ...), 16 heads, rope 64 + latent 512, page size 1, causal OK / TypeError: Expects 18 parameters OK / OK, max abs err 0.0094 vs a torch reference in both processes
flash_attn_gqa_512, 16 q heads / 2 kv heads, d=512, causal and non-causal OK / OK OK / OK, max abs err 0.0040 / 0.0098 vs a torch reference

Speed Tests and Profiling

Not applicable. This changes only the kernel signature and its call site; the kernel body is unchanged.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #37588102320
Latest PR Test (Extra): ❌ Run #37588102170
Latest PR Test (AMD ROCm 10): ❌ Run #37588102252

sgl-project#42239 added `mValue` to `FlashAttentionMLAForwardSm100.__call__` as a
keyword-only parameter after `stream`. The MLA (qv) path in interface.py
calls the kernel with 17 positional arguments. A fresh compile accepts
that, but the object the persistent CuTe JIT cache exports and later
reloads requires every parameter before the implicit TVM-FFI stream. So
every process after the first on a runner fails with "Expects 18
parameters", which breaks test_full_cuda_graph_prefill.py on B200 CI.

Put `mValue` before `stream`, restore the stream-last comment, and pass
`mValue=None` explicitly at the qv compile and call sites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nvpohanh

nvpohanh commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py

@nvpohanh

nvpohanh commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py::TestFullCudaGraphChunkedPrefix.test_cached_prefix_replays_full_cuda_graph test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py::TestFullCudaGraphChunkedPrefix.test_cached_prefix_replays_two_64_token_full_cuda_graph_chunks test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🚀 4-gpu-b200 (3 tests): ✅ View workflow run

cd test/ && python3 registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py TestFullCudaGraphChunkedPrefix.test_cached_prefix_replays_full_cuda_graph
cd test/ && python3 registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py TestFullCudaGraphChunkedPrefix.test_cached_prefix_replays_two_64_token_full_cuda_graph_chunks
cd test/ && python3 registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py

@nvpohanh

nvpohanh commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

force-merge this since this is a very limited-scope change and will unblock CI stage-b

@nvpohanh
nvpohanh merged commit ba77d30 into sgl-project:main Oct 7, 2026
101 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] test_full_cuda_graph_prefill.py fails on main: FA4 MLA "Expects 18 parameters" after a disk-cached kernel load

1 participant