Skip to content

Prototype NVFP4 with FP8 UE5M3 block scales - #3325

Open
timmoon10 wants to merge 33 commits into
NVIDIA:mainfrom
timmoon10:nvfp4-ue5m3-prototype
Open

Prototype NVFP4 with FP8 UE5M3 block scales#3325
timmoon10 wants to merge 33 commits into
NVIDIA:mainfrom
timmoon10:nvfp4-ue5m3-prototype

Conversation

@timmoon10

@timmoon10 timmoon10 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Description

This is a proof-of-concept for NVFP4 with FP8 UE5M3 block scales. Quantization is supported natively and GEMMs go through the cuDNN Frontend kernels (see NVIDIA/cudnn-frontend#545).

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

  • Support NVFP4 tensors with UE5M3 scales
  • Support UE5M3 scales in NVFP4 quantize/dequantize kernels
  • Support UE5M3 scales in NVFP4 quantizers

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

Co-authored-by: Teddy Do <tdophung@nvidia.com>
Co-authored-by: Varun Thumbe <vthumbe@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10 timmoon10 added the enhancement New feature or request label Aug 7, 2026
@timmoon10

This comment was marked as outdated.

* [PyTorch] Enable e5m3 fused GEMM kernels from cuDNN

Signed-off-by: Kaining Zhong <kainingz@nvidia.com>

* have to pad to 256 to use cuDNN

Signed-off-by: Kaining Zhong <kainingz@nvidia.com>

* fix: need to pass scale_dtype

Signed-off-by: Kaining Zhong <kainingz@nvidia.com>

* route wgrad to cuDNN's wgrad API

Signed-off-by: Kaining Zhong <kainingz@nvidia.com>

* Support grouped linear with NVFP4-UE5M3

NVFP4-UE5M3 grouped GEMM falls back to dense GEMMs. Generalize usage of wgrad kernel and use when tensors sizes are not 256-aligned. Fix inconsistent m,n,k GEMM notation. Remove ue5m3 hacks in op fuser tests. Add ue5m3 to grouped MLP tests.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix typos

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Co-authored-by: Tim Moon <tmoon@nvidia.com>
Co-authored-by: Codex <noreply@openai.com>
Comment thread transformer_engine/pytorch/cpp_extensions/gemm.py Outdated
Comment thread transformer_engine/common/include/transformer_engine/recipe.h
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10
timmoon10 force-pushed the nvfp4-ue5m3-prototype branch from 0987860 to ab3a9b3 Compare August 14, 2026 12:09
Comment thread transformer_engine/pytorch/cpp_extensions/gemm.py Outdated
timmoon10 and others added 5 commits August 14, 2026 12:44
@timmoon10
timmoon10 marked this pull request as ready for review August 17, 2026 21:35
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This proof-of-concept adds UE5M3 block-scale support throughout NVFP4 quantization, tensor metadata, bindings, GEMM paths, and tests.

  • Adds UE5M3 scale dtype and availability/configuration plumbing.
  • Updates NVFP4 quantization, dequantization, grouped GEMM, and fused grouped-MLP paths.
  • Extends C++ and PyTorch coverage for UE5M3-scaled NVFP4 tensors.

Confidence Score: 5/5

The pull request appears safe to merge because no blocking failure remains from the previously reported issues.

No blocking failure remains.

Important Files Changed

Filename Overview
transformer_engine/pytorch/ops/fused/grouped_mlp.py Propagates NVFP4 scale dtype through single-group reconstruction, safely retains unsupported-fusion fallback, and adds UE5M3-aware cuDNN grouped-GEMM handling.
transformer_engine/pytorch/tensor/nvfp4_tensor.py Extends NVFP4 quantizer and tensor metadata with validated E4M3 or UE5M3 scale types and second-level-scale configuration.
transformer_engine/pytorch/quantization.py Adds UE5M3 capability detection and creates NVFP4 quantizers with the recipe-selected block-scale dtype.
transformer_engine/common/cast/nvfp4/core_nvfp4.cuh Generalizes core NVFP4 scale processing for UE5M3 alongside existing E4M3 scaling.
transformer_engine/pytorch/csrc/quantizer.cpp Carries the new NVFP4 scale dtype across the Python-to-C++ quantizer and tensor-allocation boundary.
tests/pytorch/test_grouped_mlp.py Extends grouped-MLP coverage for the updated NVFP4 recipe and scale-format behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Recipe["NVFP4 recipe<br/>UE5M3 scale format"] --> Quantizer["NVFP4Quantizer<br/>scale_dtype"]
  Quantizer --> Tensor["NVFP4 tensor/storage<br/>FP4 data + UE5M3 scales"]
  Tensor --> Bindings["PyTorch/C++ bindings"]
  Bindings --> Kernels["Quantize/dequantize kernels"]
  Bindings --> GEMM["cuDNN grouped and dense GEMM"]
Loading

Reviews (15): Last reviewed commit: "Enable cuDNN GGEMM+GLU+RHT+quant kernel" | Re-trigger Greptile

Comment thread transformer_engine/pytorch/ops/fused/grouped_mlp.py
@timmoon10

This comment was marked as outdated.

Comment thread transformer_engine/common/include/transformer_engine/recipe.h Outdated
@timmoon10

This comment was marked as outdated.

@tdophung
tdophung force-pushed the nvfp4-ue5m3-prototype branch from 0ad7060 to cbae89d Compare August 20, 2026 18:10
Comment thread transformer_engine/pytorch/ops/fused/grouped_mlp.py
@tdophung

This comment was marked as outdated.

1 similar comment
@timmoon10

This comment was marked as outdated.

tdophung and others added 12 commits August 21, 2026 02:55
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10
timmoon10 force-pushed the nvfp4-ue5m3-prototype branch from ef16e25 to 26db2ee Compare August 21, 2026 02:59
timmoon10 and others added 4 commits August 21, 2026 03:45
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10
timmoon10 force-pushed the nvfp4-ue5m3-prototype branch from 4e9d0a4 to 0c2de5e Compare August 21, 2026 07:40
@timmoon10

Copy link
Copy Markdown
Member Author

/te-ci L1

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10

Copy link
Copy Markdown
Member Author

/te-ci L1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.19 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants