Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TE/JAX] XLA FFI calls for Softmax and FusedAttnBackward #1319

Merged
merged 7 commits into from
Nov 12, 2024

Conversation

huanghua1994
Copy link
Collaborator

@huanghua1994 huanghua1994 commented Nov 7, 2024

Description

This PR introduced the following primitives implemented with the new custom calls:

  • ScaledSoftmaxFwdPrimitive
  • ScaledSoftmaxBwdPrimitive
  • ScaledMaskedSoftmaxFwdPrimitive
  • ScaledMaskedSoftmaxBwdPrimitive
  • ScaledUpperTriangMaskedSoftmaxFwdPrimitive
  • ScaledUpperTriangMaskedSoftmaxBwdPrimitive
  • FusedAttnBwdPrimitive

Also added DequantizeFFI() in transformer_engine/jax/csrc/extensions/quantization.cpp although currently no Python function calls dequantize explicitly.

All C++ functions in transformer_engine/jax/csrc/extensions have FFI after this PR.

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 refractor

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

@huanghua1994
Copy link
Collaborator Author

/te-ci jax L1

@huanghua1994
Copy link
Collaborator Author

@zlsh80826 The forward test in test_fused_attn.py is turned on in this commit, and it takes about 15 minutes to run on a single H100. I think since we need to run L1 tests for any update related to fused attention, it is better to test both the forward and backward primitives in CI.

huanghua1994 and others added 4 commits November 8, 2024 13:28
Signed-off-by: Hua Huang <huah@nvidia.com>
FusedAttnBackward passed all testes in test_fused_attn.py.
Dequantize is not used currently; finish it for completeness.

Signed-off-by: Hua Huang <huah@nvidia.com>
Signed-off-by: Hua Huang <huah@nvidia.com>
@huanghua1994
Copy link
Collaborator Author

CI L1 tests passed. Rebase to the main branch to verify #1314

@huanghua1994
Copy link
Collaborator Author

/te-ci jax L1

Signed-off-by: Hua Huang <huah@nvidia.com>
.
Signed-off-by: Hua Huang <huah@nvidia.com>
@huanghua1994
Copy link
Collaborator Author

/te-ci jax L1

Copy link
Collaborator

@zlsh80826 zlsh80826 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the fused attn

Copy link
Collaborator

@phu0ngng phu0ngng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huanghua1994 huanghua1994 merged commit 237b493 into NVIDIA:main Nov 12, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants