[PyTorch] Add head-parallel FA4 backward for cuDNN CP attention - #3510
Open
bzantium wants to merge 3 commits into
Open
[PyTorch] Add head-parallel FA4 backward for cuDNN CP attention#3510bzantium wants to merge 3 commits into
bzantium wants to merge 3 commits into
Conversation
Signed-off-by: ryan.u <ryan.u@kakaocorp.com>
bzantium
marked this pull request as draft
September 11, 2026 12:34
Contributor
|
Signed-off-by: ryan.u <ryan.u@kakaocorp.com>
bzantium
marked this pull request as ready for review
September 11, 2026 12:52
Signed-off-by: ryan.u <ryan.u@kakaocorp.com>
Author
|
I checked the failed Build jobs on 37813c6:
These failures occurred before the attention tests. Lint, license, documentation, and minimum-version checks passed. The new workflows on b517bbf are awaiting maintainer approval ( |
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.
Description
Add an opt-in path that keeps cuDNN's P2P context-parallel forward and uses head-parallel FlashAttention-4 for backward. The saved attention tensors are packed into one all-to-all before backward, and the three gradients return in a second exchange. Packing preserves the FP32 log-sum-exp values and reuses the send allocation for the unpacked tensors.
The path targets causal FP16/BF16 attention on SM100 with CP2/4/8. Enable it with
NVTE_FUSED_ATTN_CP_USE_FAv4_BWD=1; unsupported configurations retain the existing backward implementation.Type of change
Changes
Validation
B200, 32K sequence, BF16, 32 heads, QK/V dimensions 192/128. Native–mixed–mixed–native order, 50 synchronized graph replays per run; maximum across ranks per sample, then median of run medians. These are attention forward/backward times and incremental allocated peaks during graph capture/replay, excluding projections, MoE, optimizer and checkpoint I/O.
The benchmark uses CUDA 13.1, PyTorch 2.11.0a0 (NGC 26.02), cuDNN 9.20, FA4 commit
71bf77cand CUTLASS DSL 4.5.1. CP2 is slower in this configuration, so this remains opt-in.NVTE_TEST_CP_LARGE_STRIDE=1because it needs 6 GiB per rank.pre-commit run --all-files, production-file pylint and the license check pass.Reproduce a benchmark row from the repository root with the dependencies above:
Checklist: