Skip to content

[Common] Optimize grouped MXFP8 requantization - #3560

Open
Oleg-Goncharov wants to merge 2 commits into
NVIDIA:mainfrom
Oleg-Goncharov:pr_requantize_mxfp8_perf
Open

Oleg-Goncharov wants to merge 2 commits into
NVIDIA:mainfrom
Oleg-Goncharov:pr_requantize_mxfp8_perf

Conversation

@Oleg-Goncharov

Copy link
Copy Markdown
Collaborator

Description

Add a fused grouped MXFP8 requantization path for Blackwell GPUs. The new operation converts compact rowwise MXFP8 input into columnwise E4M3 MXFP8 without materializing an intermediate high-precision tensor in global memory.

This reduces memory traffic compared with separate grouped dequantization and quantization calls. The kernel uses a tiled TMA pipeline and packed data movement/conversion operations, and supports both compact and GEMM-swizzled output scaling factors. The quantization configuration selects either an FP32 intermediate or a faster BF16 intermediate.

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

Please list the changes introduced in this PR:

  • Add the nvte_group_requantize_mxfp8 C API for fused grouped rowwise-to-columnwise MXFP8 requantization.
  • Add an SM100+ TMA-based kernel supporting grouped tensors, FP8 input types, E4M3 output, and compact or GEMM-swizzled output scales.
  • Add optimized BF16 fast-math and FP32 intermediate-precision paths.
  • Optimize packed data access and conversion in the requantization kernel.
  • Add parameterized C++ correctness tests comparing the fused operation against separate dequantization and quantization.

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

@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] Replaces grouped MXFP8 requantization kernel with new implementation.

Fix the missing CuTeDSL bridge interfaces before merging.

Findings

  1. P1 CuTeDSL builds fail ▶

Summary

Replaces the earlier fused path with grouped MXFP8 requantization and adds a CuTeDSL backend.

  • Grouped MXFP8 requantization converts rowwise input to columnwise E4M3 output in one operation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Compact rowwise MXFP8] --> B[Grouped requantize API]
  B --> C{CuTeDSL available?}
  C -->|Yes| D[CuTeDSL kernel]
  C -->|No| E[CUDA kernel]
  D --> F[Columnwise E4M3 and scales]
  E --> F
  D --> G[Optional BF16 output]
  E --> G
Loading

Reviews (11) · Last reviewed commit: "Merge main into pr_requantize_mxfp8_perf" · Reviewed by Greptile

Comment thread transformer_engine/common/cast/dispatch/quantize.cuh Outdated
Comment thread transformer_engine/common/cast/dispatch/quantize.cuh Outdated
Comment thread transformer_engine/common/cast/dispatch/gated.cuh Outdated
Comment thread transformer_engine/common/cast/dispatch/dequantize.cuh Outdated
Comment thread tests/cpp/CMakeLists.txt Outdated
Comment thread tests/cpp/operator/CMakeLists.txt Outdated
Comment thread tests/cpp/operator/test_requantize_mxfp8_grouped.cu Outdated
@ptrendx

ptrendx commented Sep 23, 2026

Copy link
Copy Markdown
Member

@Oleg-Goncharov This PR seems to have some unrelated changes (like the nccl ep submodule). Could you fix that?

@ptrendx ptrendx self-assigned this Sep 30, 2026
@ptrendx ptrendx added the 2.21 label Sep 30, 2026
@ptrendx
ptrendx requested a review from ksivaman as a code owner October 1, 2026 18:59
Comment thread transformer_engine/common/cast/mxfp8/requantize_mxfp8.cu
Comment thread transformer_engine/common/cast/mxfp8/requantize_mxfp8.cu
@ptrendx
ptrendx force-pushed the pr_requantize_mxfp8_perf branch from de60011 to b18d27e Compare October 2, 2026 23:08
Comment thread tests/cpp/operator/test_requantize_mxfp8_grouped.cu
@ptrendx ptrendx changed the title [Commo] Optimize grouped MXFP8 requantization [Common] Optimize grouped MXFP8 requantization Oct 8, 2026
@Oleg-Goncharov
Oleg-Goncharov force-pushed the pr_requantize_mxfp8_perf branch from 2ecaf5f to 1e63df7 Compare October 9, 2026 14:38
@Oleg-Goncharov

Copy link
Copy Markdown
Collaborator Author

/te-ci

@ptrendx

ptrendx commented Oct 9, 2026

Copy link
Copy Markdown
Member

@Oleg-Goncharov Please sign every commit in this PR. See https://github.com/NVIDIA/TransformerEngine/blob/main/CONTRIBUTING.rst#sign-your-work

Signed-off-by: Oleg Goncharov <[email protected]>
@Oleg-Goncharov
Oleg-Goncharov force-pushed the pr_requantize_mxfp8_perf branch from 1e63df7 to ba75d00 Compare October 9, 2026 21:06
Keep the replacement grouped MXFP8 requantization implementation and retain the new CUDA sources from main.

Signed-off-by: Przemek Tredak <[email protected]>
.value_or(false);
}

std::optional<tvm_ffi_bridge::TVMFFIKernel> get_kernel() const {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 CuTeDSL builds fail

MXFP8RequantConfig::get_kernel uses tvm_ffi_bridge::TVMFFIKernel and make_tvm_ffi_kernel, but neither exists in the repository. Builds with NVTE_WITH_CUTEDSL=ON therefore fail while compiling this header, even when the backend is disabled at runtime.

Use std::optional<tvm::ffi::Function> throughout the cache, as the existing bridge expects.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants