Skip to content

[Pytorch] Optimize CPU overhead for NCCL EP eager mode - #3378

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

[Pytorch] Optimize CPU overhead for NCCL EP eager mode#3378
YangFei1990 wants to merge 2 commits into
NVIDIA:mainfrom
YangFei1990:ncclep_cpu_overhead

Conversation

@YangFei1990

@YangFei1990 YangFei1990 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Reduce NCCL EP CPU overhead by using pinned memory CPU tensor.

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

Signed-off-by: YangFei1990 <feiw@nvidia.com>
@YangFei1990
YangFei1990 marked this pull request as ready for review August 13, 2026 21:51
@YangFei1990
YangFei1990 requested a review from ksivaman as a code owner August 13, 2026 21:51
@YangFei1990
YangFei1990 requested a review from phu0ngng August 13, 2026 21:52
@YangFei1990

Copy link
Copy Markdown
Collaborator Author

/te-ci L1 pytorch

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reduces eager-mode expert-parallel receive-count readback overhead by having the prepare operation write directly into pinned host memory.

  • Allocates total_recv_tokens in pinned CPU memory for eager mode while retaining device storage for fixed-capacity mode.
  • Explicitly synchronizes the active CUDA stream before reading the host-resident count.
  • Updates API documentation and comments to describe the mode-dependent tensor placement.

Confidence Score: 5/5

The PR appears safe to merge with no actionable changed-code failures identified.

The eager path preserves the required producer-before-host-read ordering while avoiding a pageable device-to-host transfer, and the non-eager graph path retains its device-resident counter.

Important Files Changed

Filename Overview
transformer_engine/pytorch/ep.py Changes eager EP receive-count storage from device memory to pinned host memory and synchronizes its producer stream before sizing dispatch outputs; no actionable changed-code defect was established.

Reviews (1): Last reviewed commit: "Merge branch 'main' into ncclep_cpu_over..." | 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