Skip to content

[Common][PyTorch] EP dispatch with unfused MXFP8 quantization - #3270

Merged
phu0ngng merged 16 commits into
NVIDIA:mainfrom
phu0ngng:ep_mxfp8
Aug 12, 2026
Merged

[Common][PyTorch] EP dispatch with unfused MXFP8 quantization#3270
phu0ngng merged 16 commits into
NVIDIA:mainfrom
phu0ngng:ep_mxfp8

Conversation

@phu0ngng

Copy link
Copy Markdown
Collaborator

Description

This PR adds MXFP8 support to the dispatch op of the NCCL EP path. The dispatch op is used in two places, and MXFP8 applies to both:

  • Dispatch forward bfloat16 tokens are quantized to MXFP8 internally and dispatched to the target experts; recv is returned as a per-expert GroupedTensor.
  • Combine backward the result-grad is scattered back to expert positions through the same (reverse) dispatch op, quantized to MXFP8, returning the expert-output grad as a per-expert GroupedTensor.

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

PyTorch frontend (transformer_engine/pytorch/ep.py, distributed.py, csrc/extensions/ep.cpp)**

  • The dispatch op quantizes bfloat16 tokens to MXFP8 internally when the buffer's dispatch_quant_recipe is set (MXFP8BlockScaling only for now); dispatch-forward recv is returned as a per-expert GroupedTensor. A pre-quantized input is rejected.
  • Combine backward reuses the dispatch op to scatter the result-grad: it quantizes the grad to MXFP8 and returns the expert-output grad as a per-expert GroupedTensor. Combine forward is unchanged (high-precision).
  • Recv data and block scales share a single caller-supplied (optionally symm-mem-backed) buffer, sliced into data-then-scale regions; the same convention is used for the combine backward grad buffer.

Common backend (common/ep/ep_backend.cpp, include/.../ep.h, comm_window.h)**

  • Backend and public headers extended to carry block-scale buffers/windows through the dispatch primitive.

NCCL EP submodule**

  • Bumped 3rdparty/nccl-extensions to the revision providing block-scaled dispatch.

Tests (tests/cpp_distributed/test_ep.cu, tests/pytorch/distributed/run_ep.py, run_test_ep.sh)**

  • Added C++ distributed coverage for the MXFP8 dispatch path.
  • Added PyTorch MXFP8 test passes for dispatch forward (normal, zero-copy, eager IO modes) and combine backward, gated behind a dedicated NVTE_EP_MXFP8_PASS run since the grouped path pins the per-expert alignment process-wide.

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-appsBot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds unfused MXFP8 quantization support to NCCL expert-parallel dispatch and combine backward.

  • Routes MXFP8 data and block scales through common and PyTorch dispatch interfaces.
  • Returns per-expert quantized outputs as grouped tensors and supports caller-provided or symmetric-memory-backed buffers.
  • Extends distributed tests for normal, zero-copy, eager, and combine-backward paths.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains, and the previously reported ignore-file deletion has been fully restored in the current tree.

Important Files Changed

FilenameOverview
transformer_engine/pytorch/ep.pyAdds MXFP8 recipe handling, compact scale-buffer allocation, grouped output construction, and quantized combine-backward dispatch.
transformer_engine/pytorch/csrc/extensions/ep.cppExtends PyTorch bindings to validate, describe, and route MXFP8 data and scale-inverse tensors.
transformer_engine/common/ep/ep_backend.cppAdds NCCL descriptors and dispatch configuration for block-scaled token data and scales.
transformer_engine/pytorch/distributed.pyAdds explicit symmetric-memory pool lifecycle and cache cleanup needed by EP buffers.
tests/pytorch/distributed/run_ep.pyAdds MXFP8 dispatch and combine-backward coverage across fixed, eager, caller-buffer, and zero-copy modes.

Sequence Diagram

sequenceDiagram
participant Caller
participant PyEP as PyTorch EP
participant Quant as MXFP8 Quantizer
participant Backend as NCCL EP Backend
participant Expert
Caller->>PyEP: ep_dispatch(BF16 tokens)
PyEP->>Quant: quantize data and block scales
Quant-->>PyEP: E4M3 data + E8M0 scales
PyEP->>Backend: dispatch data and scales
Backend-->>Expert: per-expert GroupedTensor
Expert->>PyEP: ep_combine(expert output)
PyEP-->>Caller: high-precision combined result
Caller->>PyEP: result gradient
PyEP->>Quant: quantize gradient
PyEP->>Backend: reverse dispatch data and scales
Backend-->>Expert: grouped expert-output gradient
Loading

Reviews (10): Last reviewed commit: "Merge branch 'main' into ep_mxfp8" | Re-trigger Greptile

@phu0ngng
phu0ngng requested a review from zhongbozhuJuly 28, 2026 23:33
Comment threadtransformer_engine/pytorch/ep.py Outdated
@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1 pytorch

Comment thread.gitignore
Comment threadtransformer_engine/pytorch/ep.py Outdated
Comment threadtransformer_engine/pytorch/ep.py
Comment threadtransformer_engine/pytorch/ep.py Outdated
Comment threadtransformer_engine/pytorch/ep.py Outdated
Comment threadtransformer_engine/pytorch/ep.py
Comment threadtransformer_engine/pytorch/ep.py Outdated
Comment threadtransformer_engine/pytorch/distributed.py Outdated
Comment threadtransformer_engine/pytorch/distributed.py
Comment threadtransformer_engine/pytorch/ep.py
Comment threadtransformer_engine/pytorch/ep.py Outdated
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
…der CUDA graph capture
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
…CUDA-graph capture
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1

@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1

@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1

@YangFei1990
YangFei1990 self-requested a review August 10, 2026 04:13

@YangFei1990YangFei1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Need to further align on API contracts before merging

YangFei1990
YangFei1990 previously approved these changes Aug 10, 2026
@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1

Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci L1

@phu0ngng
phu0ngng merged commit 56a05e7 into NVIDIA:mainAug 12, 2026
10 of 14 checks passed
@phu0ngng
phu0ngng deleted the ep_mxfp8 branch August 12, 2026 02:05
Sign up for freeto 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.

3 participants

@phu0ngng@YangFei1990@timmoon10