[Common][PyTorch] EP dispatch with unfused MXFP8 quantization - #3270
[Common][PyTorch] EP dispatch with unfused MXFP8 quantization#3270phu0ngng wants to merge 11 commits into
Conversation
Greptile SummaryAdds unfused MXFP8 quantization to NCCL expert-parallel dispatch and combine backward.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant PyTorch as PyTorch EP
participant Quantizer as MXFP8 Quantizer
participant Backend as Common EP Backend
participant NCCL as NCCL EP
Caller->>PyTorch: ep_dispatch(BF16 tokens)
PyTorch->>Quantizer: Quantize data and block scales
Quantizer-->>PyTorch: E4M3 data + E8M0 scales
PyTorch->>Backend: Dispatch data and scale windows
Backend->>NCCL: Route data and scales together
NCCL-->>PyTorch: Per-expert routed buffers
PyTorch-->>Caller: MXFP8 GroupedTensor
Caller->>PyTorch: ep_combine backward(result gradient)
PyTorch->>Quantizer: Quantize gradient
PyTorch->>Backend: Reverse dispatch data and scales
Backend->>NCCL: Scatter gradient to expert positions
PyTorch-->>Caller: Per-expert MXFP8 gradient
Reviews (5): Last reviewed commit: "[PyTorch] Drop unused device param from ..." | Re-trigger Greptile |
|
/te-ci L1 pytorch |
| return _SYMM_MEM_POOL | ||
|
|
||
|
|
||
| def release_symm_mem_pool(device: Optional[torch.device] = None) -> None: |
There was a problem hiding this comment.
This is great, shall we also call it in ep_finalize?
There was a problem hiding this comment.
release_symm_mem_pool is only required before destroy_process_group().
User may call ep_finalize without destroy_process_group().
There was a problem hiding this comment.
Hmm why is that? I did not have it in mcore but it seems working (could be luck)
There was a problem hiding this comment.
Also just see input device is never used, shall we remove?
There was a problem hiding this comment.
On why
release_symm_mem_pool is only required before destroy_process_group().
I think destroy_process_group() deletes the NCCL communicator that is used to create the symmem, so the cached symmem-s become limbo.
Are you calling destroy_process_group() in MCore? Why?
There was a problem hiding this comment.
Mcore shutdown will call destroy_process_group
There was a problem hiding this comment.
Good to know.
Anyway, I found out that release_symm_mem_pool is idempotent, so I added it to ep_finalize as you suggested.
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>
|
/te-ci L1 |
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:
GroupedTensor.GroupedTensor.Type of change
Changes
PyTorch frontend (
transformer_engine/pytorch/ep.py,distributed.py,csrc/extensions/ep.cpp)**dispatch_quant_recipeis set (MXFP8BlockScalingonly for now); dispatch-forward recv is returned as a per-expertGroupedTensor. A pre-quantized input is rejected.GroupedTensor. Combine forward is unchanged (high-precision).Common backend (
common/ep/ep_backend.cpp,include/.../ep.h,comm_window.h)**NCCL EP submodule**
3rdparty/nccl-extensionsto the revision providing block-scaled dispatch.Tests (
tests/cpp_distributed/test_ep.cu,tests/pytorch/distributed/run_ep.py,run_test_ep.sh)**NVTE_EP_MXFP8_PASSrun since the grouped path pins the per-expert alignment process-wide.Checklist: