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

[common] Generalized MXFP8 gated kernels w.r.t. input tensor dimensions #1449

Merged
merged 17 commits into from
Feb 5, 2025

Conversation

Oleg-Goncharov
Copy link
Collaborator

@Oleg-Goncharov Oleg-Goncharov commented Feb 1, 2025

Description

This PR lifts the restrictions on the shape of the input tensor for gated MXFP8 fused kernels. Similar to PR#1437, it allows an arbitrary number of rows (or the product of all tensor dimensions except the last of high-dimensional tensors).
The number of columns (or the dimensionality of the last dimension of high-dimensional tensors) must be a multiple of 32.

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

Changes

  • Removed the isFullTile requirement in the quantize_gated function.
  • Added second tensor of scaling factors for gate- part of the gated output tensor.
  • Gated MXFP8 Test Suite: Added the alignment/padding requirement for dimensions of the tensors with scaling factors to be multiples of [128,4] for row-wise and [4,128] for column-wise scaling.
  • Restricted the last dimension of the gated input tensor to multiple of 32.
  • Modified exp2f_rcp function in the testing suites, so it returns 1.0 if the biased_exp==0 to avoid NaN in the amax=0 scenario.
  • Commented out NVTE_CHECK in the CheckScaleTensorShape of the transformer_engine.cpp to suppress errors generated for the tensor shapes that are now supported.
  • Added additional tensor descriptor into gated kernels to properly handle boundaries of the activation and the gate- part of the input/output tensors.
  • Refactored the test suite.

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

Signed-off-by: Oleg Goncharov <ogoncharov@nvidia.com>
@Oleg-Goncharov Oleg-Goncharov added bug Something isn't working testing Improvements to tests or testing infrastructure 2.0.0 labels Feb 1, 2025
Copy link
Collaborator

@timmoon10 timmoon10 left a comment

Choose a reason for hiding this comment

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

LGTM, pending testing. Started pipeline 23308831.

tests/cpp/operator/test_cast_mxfp8_gated_swiglu.cu Outdated Show resolved Hide resolved
tests/cpp/operator/test_cast_mxfp8_gated_swiglu.cu Outdated Show resolved Hide resolved
transformer_engine/common/transformer_engine.cpp Outdated Show resolved Hide resolved
transformer_engine/common/transformer_engine.cpp Outdated Show resolved Hide resolved
Oleg-Goncharov and others added 12 commits February 4, 2025 01:01
Signed-off-by: Oleg Goncharov <ogoncharov@nvidia.com>
Signed-off-by: Oleg Goncharov <ogoncharov@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Oleg Goncharov <ogoncharov@nvidia.com>
Signed-off-by: Oleg Goncharov <ogoncharov@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
@ptrendx ptrendx merged commit ce8b127 into NVIDIA:release_v2.0 Feb 5, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0.0 bug Something isn't working testing Improvements to tests or testing infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants