[JAX] [PyT] [Common] Enable D=256 BWD cuDNN fused attn for Blackwell CC 10.x - #3056
[JAX] [PyT] [Common] Enable D=256 BWD cuDNN fused attn for Blackwell CC 10.x #3056KshitijLakhani wants to merge 31 commits into
Conversation
51ad582 to
d177ecf
Compare
Greptile SummaryThis PR enables SM10x D=256 fused-attention backward dispatch and expands corresponding JAX and PyTorch coverage.
Confidence Score: 3/5The PR is not yet safe to merge until THD D=256 execution-plan support at the new cuDNN 9.25 threshold is verified or the selector excludes THD. The selector now routes THD D=256 backward to the cuDNN backend at version 9.25, but the available evidence does not establish that the previously reported execution-plan failure is resolved; if it remains, plan construction raises a hard runtime error without fallback. Files Needing Attention: transformer_engine/common/fused_attn/fused_attn.cpp Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["JAX / PyTorch attention"] --> B["Common fused-attention selector"]
B --> C{"SM10x D=256 constraints satisfied?"}
C -- "No" --> D["No fused backend / framework fallback"]
C -- "Yes" --> E["NVTE_F16_arbitrary_seqlen"]
E --> F["cuDNN execution-plan validation and build"]
F --> G["D=256 backward"]
Reviews (18): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
e317f99 to
e08e9e8
Compare
5063b39 to
55f3bb4
Compare
|
Latest testing: Pipeline [56553160] |
a678b84 to
ba0cb94
Compare
|
/te-ci L2 |
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
for more information, see https://pre-commit.ci
…n fused attn Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
88217fd to
06eee35
Compare
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
|
Latest testing: Pipeline [58978691] |
| ), | ||
| ), | ||
| ], | ||
| ) |
There was a problem hiding this comment.
No problem with the "id", but it seems inconsistent with other PyTorch tests. Also, please check the 9.30 vs 9.25 version guard.
There was a problem hiding this comment.
Could you remove the 'id' fields actually - they just look really odd sitting next to other tests with no 'id's. :D
| "cp_hd256_causal": ModelConfig(2, 1024, 16, 256, attn_mask_type="causal"), | ||
| "cp_hd256_causal_swa": ModelConfig( | ||
| 2, 1024, 16, 256, attn_mask_type="causal", window_size=(128, 0) | ||
| ), |
There was a problem hiding this comment.
Should we test no_mask, padding_causal as well, or not really?
There was a problem hiding this comment.
I think it's okay to not test those two, if you are fine with it ?
The non-CP tests cover no_mask and I believe THD CP anyways translates to padding_causal under the hood, so I decided to keep this lightweight.
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
da25221 to
e3032d3
Compare
for more information, see https://pre-commit.ci
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
078c80f to
9921b99
Compare
for more information, see https://pre-commit.ci
|
Latest testing: Pipeline 59713381 |
| ), | ||
| ], | ||
| ) | ||
| def test_dpa_fused_attn_d256(dtype, model_configs, model, qkv_layout): |
There was a problem hiding this comment.
I think we can remove the "fused_xx" keyword from model_configs_fused_d256, fused_d256_no_mask, and test_dpa_fused_attn_d256. Those tests will run both unfused/flash and fused for comparison. Maybe there's no need to restrict it to "fused". Essentially what we want to test here is d256.
cyanguwa
left a comment
There was a problem hiding this comment.
Other than the two nits (test name change and 'id' removal), looks good!
| // Blackwell rejects dBias, dropout, and ALiBi (and supports vanilla softmax only). | ||
| bias_type == NVTE_Bias_Type::NVTE_NO_BIAS && dropout == 0.0 && | ||
| softmax_type == NVTE_Softmax_Type::NVTE_VANILLA_SOFTMAX && | ||
| // Non-causal D=256 supports only full-window attention; SWA is allowed only for causal masks. |
There was a problem hiding this comment.
@cyanguwa Here's the cuDNN FE restriction in this class for non-causal SWA : https://github.com/NVIDIA/cudnn-frontend/blob/c5012bd3011d28d8ffdf0307b8c213d1b97c68e0/python/cudnn/sdpa/fwd/api.py#L22 and the check is at https://github.com/NVIDIA/cudnn-frontend/blob/c5012bd3011d28d8ffdf0307b8c213d1b97c68e0/python/cudnn/sdpa/fwd/api.py#L201
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
for more information, see https://pre-commit.ci
Description
Support for D=256 BWD for Blackwell CC 10x via the C++ API (which TE uses) was added in cuDNN 9.23 + cuDNN FE 1.24 (BSHD) and cuDNN 9.30 + cuDNN FE 1.26 (THD)
Enabling this support in TE attention and adding conditional tests for the same
Type of change
Changes
Add guard when picking the backend (sub backend) in TE common.
Add tests for D=256 case in TE PyT and TE JAX
Checklist: