Skip to content

[RCCL] Fix p2p channel invariant: ensure p2pnChannels >= p2pnChannelsPerPeer - #6307

Merged
mustafabar merged 2 commits into
developfrom
users/mustafabar/rccl-p2p-channels-gfx1250
Jun 2, 2026
Merged

mustafabar merged 2 commits into
developfrom
users/mustafabar/rccl-p2p-channels-gfx1250

Conversation

@mustafabar

Copy link
Copy Markdown
Contributor

Motivation

On MI455 2x1p1g topologies, alltoall produces wrong data when topology fallback yields 2 p2p channels but the gfx1250 single-node per-peer doubling raises p2pnChannelsPerPeer to 4. The device-side helper ncclP2pChannelToPart cannot recover part indices >= nP2pChannels; higher parts silently alias onto lower ones, corrupting results.

Technical Details

  • Replaces comm->p2pnChannels = std::min(pow2Up(...), 4*CHANNEL_LIMIT) with std::min(std::max(pow2Up(comm->p2pnChannels), pow2Up(comm->p2pnChannelsPerPeer)), 4*CHANNEL_LIMIT) so p2pnChannels is always rounded up to at least p2pnChannelsPerPeer.
  • Adds a final clamp comm->p2pnChannelsPerPeer = std::min(comm->p2pnChannelsPerPeer, comm->p2pnChannels) after all arch-specific caps to preserve the invariant even when those caps shrink p2pnChannels.

JIRA ID

AICOMRCCL-1061

Test Plan

  • alltoall correctness on MI455 2x1p1g (reproducing configuration)
  • send/recv and alltoall perf on gfx1250 single-node
  • existing p2p/alltoall tests on gfx942 and gfx950

Test Result

Pending

Submission Checklist

  • Correctness verified on the reproducing topology
  • No regression in p2p channel counts on other architectures
  • Code reviewed

🤖 Generated with Claude Code

…PerPeer

Without this fix, arch-specific caps (e.g. gfx1250 per-peer doubling) could
set p2pnChannelsPerPeer higher than p2pnChannels. The device-side helper
ncclP2pChannelToPart silently aliases part indices >= nP2pChannels onto lower
ones, producing wrong data in alltoall on MI455 2x1p1g topologies.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@mustafabar
mustafabar requested a review from a team as a code owner May 20, 2026 15:24
Copilot AI review requested due to automatic review settings May 20, 2026 15:24
@mustafabar mustafabar changed the title [rccl] Fix p2p channel invariant: ensure p2pnChannels >= p2pnChannelsPerPeer [RCCL] Fix p2p channel invariant: ensure p2pnChannels >= p2pnChannelsPerPeer May 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a correctness issue in RCCL’s P2P channel selection by enforcing an invariant between the total P2P channel count (p2pnChannels) and the per-peer partitioning (p2pnChannelsPerPeer), preventing device-side channel→part inverse mapping from aliasing higher parts onto lower ones.

Changes:

  • Ensures comm->p2pnChannels is rounded/clamped to be at least comm->p2pnChannelsPerPeer (both pow2-rounded), within the existing 4*CHANNEL_LIMIT cap.
  • Adds a final safety clamp to guarantee p2pnChannelsPerPeer <= p2pnChannels after architecture-specific caps may reduce p2pnChannels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread projects/rccl/src/graph/paths.cc Resolved
Comment thread projects/rccl/src/graph/paths.cc Resolved
Comment thread projects/rccl/src/graph/paths.cc Resolved
@nileshnegi

Copy link
Copy Markdown
Contributor

LGTM. tested with alltoall on 2x1p1g, 2x1p4g, 3x1p4g, 4x1p4g.

@isaki001

Copy link
Copy Markdown
Contributor

LGTM

@mustafabar
mustafabar merged commit 79672b7 into develop Jun 2, 2026
15 checks passed
@mustafabar
mustafabar deleted the users/mustafabar/rccl-p2p-channels-gfx1250 branch June 2, 2026 14:42
sudhu2k added a commit to ROCm/Megatron-LM that referenced this pull request Oct 27, 2026
… cold-rank desync

Skip the suite-wide NCCL_MAX_NCHANNELS=1 default on ROCm. With RCCL <= 2.27.7
(ROCm 7.2.x), a low channel cap leaves fewer P2P channels than P2P parts per
peer, so send/recv messages larger than ~32 MB are silently half-delivered.
This corrupted context-parallel attention (test_thd_correctness) and the MoE
dispatcher and custom process-group tests. Fixed upstream in
ROCm/rocm-systems#6307; keep the default for CUDA.

Move TestMoriColdRank out of test_token_dispatcher_mori.py into its own
test_token_dispatcher_cold_rank_mori.py module so the zero-token EP rank case
runs in a fresh torchrun process and a regression there cannot desynchronize
the MORI op and process-group state shared by the other MORI tests.

Signed-off-by: sudhu2k <Sudharshan.Govindan@amd.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants