Add fused SBHD compressed sparse attention - #6404
Draft
FDecaYed wants to merge 10 commits into
Draft
Conversation
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
(cherry picked from commit b7c36fa) Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com> Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
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.
Add fused SBHD compressed sparse attention
Summary
Add the high-performance fused SBHD backend for DeepSeek-V4 CSA on top of the current-main DSA backend contract.
Scope
csa_utils/fused_sparse_attention.pylayout.CompressedSparseAttentionthrough the fused SBHD path when the canonical DSA backend router selects cuDNN.cudnnfordsv4_hybridand tononefor ordinary DSA; an explicitnoneremains authoritative.Production diff: 6 files, +1,206/-3. Test diff: 2 files, +182/-4.
Non-goals
dsa.py,dsa_kernels.py,dsa_cudnn_kernels.py,dsa_indexer_loss.py,dsa_layout.py, ordsa_masking.py.Review boundary and dependencies
Requires #6402 (D2). The local branch carries the complete D2 line through
0ecb394a67d2; this remains an independent PR targetingmain.5f0d068ad3d289ac2bc44ce1b3056c0d04fcdcf30ecb394a67d2ae2b89c20d8d489c48fa5b5b1ef9Please review the own commit only. After D2 merges, it will be replayed directly onto then-current
main.Provenance
Uses current-main ordinary DSA as source of truth, #6020 for the DSA/CSA ownership contract, #6372 for the current CSA helper layout, and #5960 for teacher correctness. #5795 is a historical feature/test oracle only.
Validation
Passed locally:
Signed-off-bytrailer;git diff --checkon the complete own diff;The two existing training argument files retain their parent branch's whole-file Black/isort debt; D3 adds no imports there and does not reformat unrelated code. Runtime pytest is blocked on this macOS ARM host because the cuDNN Frontend package is Linux-only and CUDA/SM90 hardware is unavailable. The real fused/native parity test is included and gated on CUDA, SM90+, cuDNN DSA, and FlashMLA; it and full functional CI must run after publication.
Required GPU evidence before merge:
dsa_kernel_backend='none'using the intended DSv4 production shape (d_v=512and supported head/top-K values).Sibling rebase constraint
D3 and #6405 (D4) are independent and can merge in either order, but both touch
megatron/training/argument_utils.pyandmegatron/training/arguments.py. If D4 merges first, D3’s rebase must preserve D4’s C/H/W variant inference and compression-ratio normalization while adding the backend-default behavior here.Local artifact
D3-fused-sbhd-csa.patch, generated from the own commit only. Verify it against SHA256SUMS.
Before publication
After D2 merges, replay only D3’s own commit onto current
main, re-audit backend APIs and optional dependencies, preserve any already-merged D4 training-argument logic, then run the focused SM90+ kernel parity test and full functional CI.