Repository navigation
fix: DeepSeek V4 cudnn_flashmla forward on SM90 - #4129
Open
mikasenghaas wants to merge 1 commit into
Open
mikasenghaas wants to merge 1 commit into
mikasenghaas wants to merge 1 commit into
Conversation
The pinned flash-mla wheel's SM90 sparse prefill kernel rejects topk_length, so every cudnn_flashmla forward on H200 raised. The slots past each query's valid prefix are already -1, which FlashMLA masks, so dropping topk_length on SM90 gives the same result. SM100 keeps it, and the cuDNN backward is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
topk_lengthto the FlashMLA sparse prefill forward on SM90 incudnn_flashmla_forward.-1, and FlashMLA masks them. SM90 now reads the whole slot width, and the result is the same.topk_length. The cuDNN backward is unchanged.Why:
Unit (GPU)onmainfails 24cudnn_flashmlacases intests/unit/train/models/test_deepseek_v4_kernels.py. It has failed since feat(deepseek-v4): cudnn_flashmla sparse attention backend (FlashMLA forward, cuDNN backward) #4078 landed.flashmla-b7643bd) raises insparse_prefill_fwd:b7643bdlistsTOPK_LENGTHas an SM90 feature. The wheel's binary prints its last two SM90 features as0: HEAD_64, so this build does not have them.Verification
Unit (GPU)onmainat68e5755ed(run) had 24 failed and 210 passed tests. All failures werecudnn_flashmlacases.Unit (GPU)on this PR.Follow-ups
flashmla_sparse_mla_forward(GLM-5,model.dsa_backend = "cudnn_flashmla") also passestopk_length, so it likely fails the same way on H200. No CI test covers that path on H200.🤖 Generated with Claude Code
Note
Low Risk
Narrow forward-path workaround for a known FlashMLA SM90 limitation; backward and non-SM90 paths unchanged, with masking preserving correctness.
Overview
Fixes DeepSeek V4
cudnn_flashmlasparse prefill on SM90 (e.g. H200) by not passingtopk_lengthintoflash_mla_sparse_fwdwhen the GPU’s major capability is 9.The pinned FlashMLA wheel’s SM90 kernel errors if
TOPK_LENGTHis requested; invalid gather slots are already-1and masked, so omittingtopk_lengthstill scans the padded width with the same numerics. SM100/SM103 behavior is unchanged—they still passtopk_length. The cuDNN backward path is untouched.Reviewed by Cursor Bugbot for commit 35c870b. Bugbot is set up for automated code reviews on this repo. Configure here.