Skip to content

[Pytorch] [NCCL EP] Allow zero tokens for an EP rank in eager mode - #3276

Open
YangFei1990 wants to merge 2 commits into
NVIDIA:mainfrom
YangFei1990:allow_ep_rank_no_data
Open

[Pytorch] [NCCL EP] Allow zero tokens for an EP rank in eager mode#3276
YangFei1990 wants to merge 2 commits into
NVIDIA:mainfrom
YangFei1990:allow_ep_rank_no_data

Conversation

@YangFei1990

Copy link
Copy Markdown
Collaborator

Description

For eager mode, there could be case where certain EP ranks do not receive any token, based on the routing strategy. This PR relax the constraint to allow such behavior.

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

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: YangFei1990 <feiw@nvidia.com>
@YangFei1990
YangFei1990 requested a review from phu0ngng July 29, 2026 18:48
@YangFei1990

Copy link
Copy Markdown
Collaborator Author

/te-ci L1

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Allows eager expert-parallel ranks to pass zero-element tensors with null data pointers into NCCL EP descriptors.

  • Relaxes tensor descriptor validation only when the tensor has zero elements.
  • Adds a distributed eager-mode forward/backward regression test where nonzero ranks receive no tokens.

Confidence Score: 5/5

The PR appears safe to merge, with the relaxed validation constrained to empty tensors and covered by an end-to-end eager expert-parallel regression test.

Non-empty tensors still require valid data pointers, while the new distributed test exercises null-backed empty receive tensors through forward dispatch, combine, and backward execution.

Important Files Changed

Filename Overview
transformer_engine/common/ep/ep_backend.cpp Safely narrows the non-null data requirement by exempting zero-element tensors while retaining validation for non-empty tensors.
tests/pytorch/distributed/run_ep.py Adds CI-reachable eager-mode coverage for zero-token ranks across dispatch, weighted expert processing, combine, and backward propagation.

Reviews (1): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | 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.

2 participants