Skip to content

[Common/PyTorch] Fused grouped MXFP8 requantization - #3359

Open
YangFei1990 wants to merge 5 commits into
NVIDIA:mainfrom
YangFei1990:fused_group_requantize
Open

[Common/PyTorch] Fused grouped MXFP8 requantization#3359
YangFei1990 wants to merge 5 commits into
NVIDIA:mainfrom
YangFei1990:fused_group_requantize

Conversation

@YangFei1990

Copy link
Copy Markdown
Collaborator

Description

Replace the group_dequantize -> group_quantize(columnwise) -> grouped_swizzle(rowwise scales) chain in group_requantize_inplace with a single kernel (NVTE_FUSED_GROUP_REQUANTIZE=0 restores the unfused path).

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

Please list the changes introduced in this PR:

  • Change A
  • Change B

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

Replace the group_dequantize -> group_quantize(columnwise) ->
grouped_swizzle(rowwise scales) chain in group_requantize_inplace with a
single kernel (NVTE_FUSED_GROUP_REQUANTIZE=0 restores the unfused path).

Co-authored-by: Oleg Goncharov <ogoncharov@nvidia.com>
Signed-off-by: YangFei1990 <feiw@nvidia.com>
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a Blackwell-only fused path for converting rowwise grouped MXFP8 tensors into GEMM-ready rowwise and columnwise representations, while retaining the existing unfused path behind an environment-variable fallback.

  • Adds the fused CUDA requantization kernel and public C API.
  • Integrates fused dispatch into PyTorch grouped requantization.
  • Adds parameterized C++ coverage for data, scales, optional BF16 output, zero-sized groups, and capacity tails.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the provided follow-up-review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
transformer_engine/common/cast/fused_group_requantize.cu Implements the Blackwell fused kernel, validation, scale-layout writes, optional BF16 materialization, and C API entry point; no eligible follow-up finding was established.
transformer_engine/pytorch/csrc/extensions/cast.cpp Selects the fused path for supported grouped MXFP8 inputs and installs the resulting buffers and metadata, with the existing implementation retained as fallback.
tests/cpp/operator/test_fused_group_requantize_mxfp8.cu Compares fused output against the production unfused chain across input formats, fast-math modes, zero-sized groups, capacity tails, and optional dequantization.
transformer_engine/common/include/transformer_engine/cast.h Declares and documents the new fused grouped requantization C API and its layout and alignment contracts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Rowwise grouped MXFP8 input] --> B{Fused path supported?}
  B -->|Yes| C[Fused grouped requantization kernel]
  C --> D[Swizzled rowwise scales]
  C --> E[Columnwise E4M3 data and scales]
  C --> F[Optional BF16 output]
  B -->|No or disabled| G[Existing dequantize, quantize, and swizzle chain]
  G --> D
  G --> E
  G --> F
Loading

Reviews (2): Last reviewed commit: "Merge branch 'fused_group_requantize' of..." | Re-trigger Greptile

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.

1 participant