Skip to content

Fix issues in fused_attn_bwd - #1574

Merged
xrennvidia merged 17 commits into
NVIDIA:mainfrom
xrennvidia:xren/cp_mlperf_lora
Mar 24, 2025
Merged

Fix issues in fused_attn_bwd#1574
xrennvidia merged 17 commits into
NVIDIA:mainfrom
xrennvidia:xren/cp_mlperf_lora

Conversation

@xrennvidia

@xrennvidiaxrennvidia commented Mar 13, 2025

Copy link
Copy Markdown
Collaborator

Description

  • Fix dtypes in fused_attn_bwd for CP, and make them consistent with the similar non-CP fix in [PyTorch] Fix fused attention backward's FP8 dtypes #1566 . This helps solve some convergence issues with CP+P2P and CP+A2A, with FP8 attention.
  • Clone fwd scale for the recomputation in fused_attn_bwd: for non-CP, clone S's scale only; for CP, clone QKV, O and S's scales
  • Fix the amax update in CP+P2P

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@xrennvidia

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci pytorch L1

@cyanguwa
cyanguwa self-requested a review March 20, 2025 19:34
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
@cyanguwacyanguwa removed the 2.2.0 label Mar 22, 2025
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
@xrennvidiaxrennvidia changed the title Fix dtypes of fused_attn_bwd in CP implementation.Fix issues in fused_attn_bwdMar 22, 2025
@xrennvidia

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci pytorch L1

@cyanguwa

Copy link
Copy Markdown
Collaborator

Thanks for the offline discussion. I think the PR looks good. I tidied up the PR description a bit and added more details. Also, the redundant None issue is being addressed by #1589 as well, so I removed it from this PR's description (no biggie, I don't think there'll be conflicts or anything). Once the user confirms convergence and the CI clears, I think you can merge. Thanks!!

@xrennvidia
xrennvidia merged commit e14d147 into NVIDIA:mainMar 24, 2025
@xrennvidia
xrennvidia deleted the xren/cp_mlperf_lora branch March 24, 2025 18:02
KshitijLakhani pushed a commit that referenced this pull request Mar 24, 2025
* fix dtypes of fused_attn_bwd in CP+A2A
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* fix dtypes of fused_attn_bwd in CP+P2P
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix amax_per_step
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* clone scaling factors of fwd quantizers
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* fix fwd quantizers of CP+P2P
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* minor change
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* dequantize fp8 out in CP unit test
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* delete redundant None in FusedAttnFunc bwd
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
---------
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
lhb8125 pushed a commit to lhb8125/TransformerEngine that referenced this pull request Apr 8, 2025
* fix dtypes of fused_attn_bwd in CP+A2A
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* fix dtypes of fused_attn_bwd in CP+P2P
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix amax_per_step
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* clone scaling factors of fwd quantizers
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* fix fwd quantizers of CP+P2P
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* minor change
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* dequantize fp8 out in CP unit test
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
* delete redundant None in FusedAttnFunc bwd
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
---------
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xrennvidia@cyanguwa