-
Notifications
You must be signed in to change notification settings - Fork 806
Prototype NVFP4 with FP8 UE5M3 block scales #3325
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
Open
timmoon10
wants to merge
40
commits into
NVIDIA:main
Choose a base branch
from
timmoon10:nvfp4-ue5m3-prototype
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
25d5b4b
Prototype NVFP4 with UE5M3 scales
timmoon10 dede7c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 343c4bd
[PyTorch] Enable e5m3 fused GEMM kernels from cuDNN (#2)
kainzhong 8feb5e9
Merge branch 'main' into nvfp4-ue5m3-prototype
timmoon10 ab3a9b3
Use custom recipe for NVFP4-UE5M3 tests
timmoon10 92b1063
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3d25d20
Add grouped MLP kernel for GGEMM+SwiGLU+RHT+quant
timmoon10 f030e40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 535ea4f
Merge branch 'main' into nvfp4-ue5m3-prototype
timmoon10 e366e88
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 252ae94
Debug integration with GGEMM+GLU+RHT+quant
timmoon10 f2b9c98
Remove scale max helper functions from NVFP4 cast utils
timmoon10 8685556
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 803dd24
Fix compile error
timmoon10 27f29d0
Fix NVFP4 scale dtype ABI
tdophung c9dad3e
remove redundant output alloc
kainzhong 2bf42eb
no need to pad N now
kainzhong b6913b2
fix linting errors
kainzhong f2c26bd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 030e9af
Disable cuDNN GGEMM+GLU+RHT+quant kernel
timmoon10 9162e98
Guard NVFP4 alpha scaling by scaling mode
tdophung db0957b
Restore UE5M3 NVFP4 cast support
tdophung 982be7b
Localize NVFP4 4over6 scale policy
tdophung 01f4edc
Tweak arg order in C API functions
timmoon10 3a63623
Rename cuDNN GGEMM helper functions for general_gemm
timmoon10 26db2ee
Merge branch 'main' into HEAD
timmoon10 8e229f1
Fix compilation error in C++ test
timmoon10 c8e6ced
Treat nvfp4_e4m3_max=0 as unset value
timmoon10 6e84816
Debug torch.compile test failure
timmoon10 0c2de5e
Debug test failures
timmoon10 dd90509
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d42ccbe
Revert accidental CUTLASS commit change
timmoon10 b47e1f8
Enable cuDNN GGEMM+GLU+RHT+quant kernel
timmoon10 ae3020f
Remove incorrect scale_inv_dtype arg to NVFP4Tensor constructor
timmoon10 1d0d56f
Fix bug when selecting cuDNN GGEMM+GLU+RHT+quant kernel
timmoon10 b8fa24d
Restore GGEMM+GLU+RHT+amax kernel with RHT sign mask
timmoon10 30b8af8
Debug minor test failures
timmoon10 d9b633d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 75bdfe4
Fix incorrect scale dtypes in grouped tensor builder method
timmoon10 58dfc41
Avoid redundant amax ptr check in row-scaled NVFP4 quantize
timmoon10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,9 @@ bool areShapesEqual(const NVTEShape &s1, const NVTEShape &s2) { | |
| } | ||
|
|
||
| size_t typeToNumBits(DType type) { | ||
| if (type == DType::kFloat8UE5M3) { | ||
| return 8; | ||
| } | ||
| TRANSFORMER_ENGINE_TYPE_SWITCH_ALL(type, T, | ||
| { | ||
| return TypeInfo<T>::size; | ||
|
|
@@ -65,6 +68,7 @@ const std::string &typeName(DType type) { | |
| {DType::kBFloat16, "bfloat16"}, | ||
| {DType::kFloat8E4M3, "float8e4m3"}, | ||
| {DType::kFloat8E5M2, "float8e5m2"}, | ||
| {DType::kFloat8UE5M3, "float8ue5m3"}, | ||
| {DType::kFloat8E8M0, "float8e8m0"}, | ||
| {DType::kFloat4E2M1, "float4e2m1"}}; | ||
| return name_map.at(type); | ||
|
|
@@ -278,7 +282,7 @@ void Tensor::Buffer::from_cpu() { | |
| Tensor::Tensor(const std::string& name, | ||
| const NVTEShape &shape, const DType type, | ||
| const bool rowwise, const bool columnwise, | ||
| const NVTEScalingMode &scaling_mode) | ||
| const NVTEScalingMode &scaling_mode, const DType scale_dtype) | ||
| : tensor_(scaling_mode), rowwise_{rowwise}, columnwise_{columnwise}, name_{name} { | ||
| // Initialize RNG | ||
| const size_t seed = create_seed_from_tensor_name(name); | ||
|
|
@@ -374,6 +378,14 @@ Tensor::Tensor(const std::string& name, | |
| { | ||
| // Block scaling factors | ||
| auto [rowwise_scale_meta, colwise_scale_meta] = get_scales(flattened_shape, tensor_.scaling_mode()); | ||
| if (scaling_mode == NVTE_NVFP4_1D_SCALING) { | ||
| NVTE_CHECK(scale_dtype == DType::kFloat8E4M3 || | ||
| scale_dtype == DType::kFloat8UE5M3); | ||
| rowwise_scale_meta.type = scale_dtype; | ||
| rowwise_scale_meta.type_size_bits = typeToNumBits(scale_dtype); | ||
| colwise_scale_meta.type = scale_dtype; | ||
| colwise_scale_meta.type_size_bits = typeToNumBits(scale_dtype); | ||
| } | ||
|
Comment on lines
+381
to
+388
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be part of the get_scales function, no? |
||
| if (rowwise) { | ||
| const auto scale_shape = rowwise_scale_meta.shape; | ||
| const auto scale_dtype = rowwise_scale_meta.type; | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? Why do we need to specialcase it?