Skip to content

[CP] Work around Ulysses graph registration on older NCCL - #5393

Merged
fegin merged 6 commits into
mainfrom
gh/fegin/186/head
Oct 17, 2026
Merged

fegin merged 6 commits into
mainfrom
gh/fegin/186/head

Conversation

@fegin

@fegin fegin commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

NCCL may reuse an incomplete CUDA-graph IPC mapping for another buffer view. This can cause incorrect results or invalid memory access. Set NCCL_GRAPH_REGISTER=0 before process-group initialization for normal Ulysses on NCCL releases before 2.32.3.

The affected NCCL registration code is shared with other collective paths, including all-gather and some out-of-place all-reduce paths. This workaround is scoped to normal Ulysses because that is the confirmed reproduction. We currently couldn't reproduce this issues with other collectives, so we just enable the workaround for Ulysses.

Reproduced the error on a smaller scale, need a larger scale run of Kimi K3 to verify.

Upstream fix: NVIDIA/nccl#2362. The first fixed public release is NCCL 2.32.3.

fegin added 2 commits October 14, 2026 09:28
[ghstack-poisoned]
[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 14, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@fegin fegin changed the title Work around Ulysses graph registration on older NCCL [CP] Work around Ulysses graph registration on older NCCL Oct 14, 2026
Comment thread torchtitan/training_engine.py Resolved
if not any(model.traverse(UlyssesCPInnerAttention.Config)):
return

_warn_overwrite_env("NCCL_GRAPH_REGISTER", "0")

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.

so this will also affect other collectives if we turn this flag on when using Ulysses? is there any impact?

@fegin fegin Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, performance regressions, extra copy. But whether we will actually see performance regressions depends on the actual workloads.

[ghstack-poisoned]
fegin added a commit that referenced this pull request Oct 14, 2026
NCCL may reuse an incomplete CUDA-graph IPC mapping for another buffer view. This can cause incorrect results or invalid memory access. Set NCCL_GRAPH_REGISTER=0 before process-group initialization for normal Ulysses on NCCL releases before 2.32.3.

The affected NCCL registration code is shared with other collective paths, including all-gather and some out-of-place all-reduce paths. This workaround is scoped to normal Ulysses because that is the confirmed reproduction. We currently couldn't reproduce this issues with other collectives, so we just enable the workaround for Ulysses.

Reproduced the error on a smaller scale, need a larger scale run of Kimi K3 to verify.

Upstream fix: NVIDIA/nccl#2362. The first fixed public release is NCCL 2.32.3.


ghstack-source-id: 881da57
Pull-Request: #5393

@shuhuayu shuhuayu 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.

thx! fixed my kimi k3 run with cp and cudagraph.

device_module.set_device(self.device)
config = self.config
set_batch_invariance(config.debug.batch_invariant)
dist_utils.configure_nccl_for_ulysses(

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.

please add a TODO here, too

"""Disable graph registration on affected NCCL versions before initialization.

NCCL < 2.32.3 can reuse partial IPC imports for Ulysses graph buffers.
Fix: https://github.com/NVIDIA/nccl/pull/2362 (NCCL 2.32.3).

@tianyu-l tianyu-l Oct 15, 2026 •

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.

I heard from @shuhuayu that this problem being addressed by this PR only happens when cudagraph + Ulysses is used, which will make cudagraph perf same as eager.

I wonder if we should just ban Ulysses + cudagraph for now, and add a TODO to wait for NCCL version bump. In particular, this is a global flag which affects other parts, "unexpectedly".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tianyu-l that is only for Kimi K3. For Muse Spark, without CUDAGraph, the performance is worse.

fegin added 2 commits October 17, 2026 11:57
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Oct 17, 2026
NCCL may reuse an incomplete CUDA-graph IPC mapping for another buffer view. This can cause incorrect results or invalid memory access. Set NCCL_GRAPH_REGISTER=0 before process-group initialization for normal Ulysses on NCCL releases before 2.32.3.

The affected NCCL registration code is shared with other collective paths, including all-gather and some out-of-place all-reduce paths. This workaround is scoped to normal Ulysses because that is the confirmed reproduction. We currently couldn't reproduce this issues with other collectives, so we just enable the workaround for Ulysses.

Reproduced the error on a smaller scale, need a larger scale run of Kimi K3 to verify.

Upstream fix: NVIDIA/nccl#2362. The first fixed public release is NCCL 2.32.3.


ghstack-source-id: da351b7
Pull-Request: #5393
@fegin
fegin requested a review from tianyu-l October 17, 2026 18:58
[ghstack-poisoned]
fegin added a commit that referenced this pull request Oct 17, 2026
NCCL may reuse an incomplete CUDA-graph IPC mapping for another buffer view. This can cause incorrect results or invalid memory access. Set NCCL_GRAPH_REGISTER=0 before process-group initialization for normal Ulysses on NCCL releases before 2.32.3.

The affected NCCL registration code is shared with other collective paths, including all-gather and some out-of-place all-reduce paths. This workaround is scoped to normal Ulysses because that is the confirmed reproduction. We currently couldn't reproduce this issues with other collectives, so we just enable the workaround for Ulysses.

Reproduced the error on a smaller scale, need a larger scale run of Kimi K3 to verify.

Upstream fix: NVIDIA/nccl#2362. The first fixed public release is NCCL 2.32.3.


ghstack-source-id: f98d139
Pull-Request: #5393
@fegin
fegin changed the base branch from gh/fegin/186/base to main October 17, 2026 22:04
@fegin
fegin merged commit 8899cee into main Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants