Skip to content

[PyTorch] Enable e5m3 fused GEMM kernels from cuDNN - #2

Merged
timmoon10 merged 6 commits into
timmoon10:nvfp4-ue5m3-prototypefrom
kainzhong:nvfp4-ue5m3-prototype-cudnn
Aug 13, 2026
Merged

[PyTorch] Enable e5m3 fused GEMM kernels from cuDNN#2
timmoon10 merged 6 commits into
timmoon10:nvfp4-ue5m3-prototypefrom
kainzhong:nvfp4-ue5m3-prototype-cudnn

Conversation

@kainzhong

@kainzhong kainzhong commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Description

Route NVFP4 with e5m3 SF GEMM to cuDNN. Only applied to basic linear and fused grouped linear for now

TODO:

  • grouped_gemm_quant_wrapper_sm100 doesn't support accumulation, so I have to turn off with cfg.model.gradient_accumulation_fusion.
  • I have to pad MLA's kv_a_proj_with_mqa due to cuDNN-FE's grouped_gemm_quant_wrapper_sm100 requiring M to be divisible by 256. Maybe I can also try to use grouped_gemm_wgrad_wrapper_sm100 instead which doesn't require divisibility

The numeric seems wrong when I train DeepSeek V3. I'm still debugging it

Fixes # (issue)

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

  • general_gemm now goes to cuDNN-FE's grouped_gemm_quant_wrapper_sm100 when NVFP4 with e5m3 SF
  • grouped_mlp.py uses cuDNN-FE's Rubin kernels when NVFP4 with e5m3 SF
  • Pass scale's dtype to C++ from _cast_master_weights_to_nvfp4_2d otherwise quantization will default to e4m3 and emits wrong result

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: Kaining Zhong <kainingz@nvidia.com>
kainzhong and others added 5 commits August 12, 2026 00:49
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
Signed-off-by: Kaining Zhong <kainingz@nvidia.com>
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>
Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10
timmoon10 merged commit 343c4bd into timmoon10:nvfp4-ue5m3-prototype Aug 13, 2026
5 of 11 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.

2 participants