You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NCCL error when using non-colocated generation and set_model_state_dict apis #564
uv run pytest -vv tests/unit/models/generation/test_vllm_generation.py::test_vllm_refit_non_collocated_update_weights[2-True]
When async_engine is True, the error is the assertion error assert self.rank < self.world_size in vllm vllm/distributed/utils.py:L165, and the caller is StatelessProcessGroup.create.
TP=2, async_engine=False
uv run pytest -vv tests/unit/models/generation/test_vllm_generation.py::test_vllm_refit_non_collocated_update_weights[2-False]
The error message is sometimes as the same as above and sometimes: RuntimeError: NCCL error: internal error - please report this issue to the NCCL developers. This happens in the nccl.ncclCommInitRank.
# Disable NCCL SHM if training and generation are not co-located: https://github.com/NVIDIA-NeMo/RL/issues/564
BTW, I also met the same issue in mcore worker and needs to set the env vars to avoid it in #613.
And I also realized the slowdown in policy_training and policy_and_reference_logprobs in both dtensor and mcore worker after setting the env vars.
Just some additional info, and I think we should first focus on the issue with dtensor worker.
Basically it calls the branch of Legacy CUDA IPC and uses cudaIpcOpenMemHandle. This code path appears broken in this NCCL version in this situation.
The root casue of getting into this branch: ncclCuMemEnable is not enabled.
The flag ncclCuMemEnabled is disabled due to the environment variable override in vLLM. This was originally done to fix the extra memory usage (cosing 1~2 GiB GPU memory with cudagraph+allreduce), but we don't really need to do so (enabling CUMEM is actually better for multi-node NVLink setups).
I manually removed the NCCL_CUMEM_ENABLE=0 in our codebase and the vLLM packages (just hacking and testing), and the training now runs correctly without NCCL_P2P_DISABLE=1.
Action Items
Remove NCCL_CUMEM_ENABLE=0 from our codebase.
If/when we upgrade to vllm>=v0.9.1rc1, we only need to explicitly set the NCCL_CUMEM_ENABLE=1.
Until then, we must re-overrideNCCL_CUMEM_ENABLE=1 after vLLM sets it.
@YUki-666 could you please share performance benchmarking scripts we care about? I'd like to compare performance under different NCCL settings to make sure this change would work for performance.
I have already run with c230a4d and be05b13.
Can you run one with the same config w/ your fix? If you haven't cluster or wandb for now, can you give me a branch w/ your fix, so that I can help to run one for check.
RCCA Status: Done
RCCA Category: covered
Test Action: none
Fix PR: #613, #636
Root Cause: fix PR includes upstream test coverage.
Trigger Config: NCCL error when using non-colocated generation and set_model_state_dict apis
Coverage Assessment:
Area
Result
Existing Test
Upstream fix PR test coverage
Coverage Status
COVERED
Gap
N/A
Corrective Action
No nmfw_tests addition required; fix PR includes upstream test coverage or equivalent regression coverage.
Conclusion: RCCA classification completed for this closed NeMo-RL GitHub issue.
Activity
Disable nccl shm to fix #564
wangshangsam commentedon Jul 2, 2025
Assigning to @Dazz993
zhandaz commentedon Jul 7, 2025
@parthchadha I'm trying to reproduce this error with sha: ae54cbd.
1. from
pytestSince the testing code has changed, I’m trying with the following updated commands.
The tests pass when
TP=1.To effectively test the case where
TP=2, we should comment out these lines to avoid skipping: https://github.com/NVIDIA-NeMo/RL/blob/main/tests/unit/models/generation/test_vllm_generation.py#L1187-L1191.TP=2, async_engine=True
When
async_engineis True, the error is the assertion errorassert self.rank < self.world_sizein vllmvllm/distributed/utils.py:L165, and the caller isStatelessProcessGroup.create.TP=2, async_engine=False
The error message is sometimes as the same as above and sometimes:
RuntimeError: NCCL error: internal error - please report this issue to the NCCL developers. This happens in thenccl.ncclCommInitRank.2. from #595.
Yuki reported the error earlier in #595, with the following commands:
uv run python examples/run_grpo_math.py \ policy.generation.colocated.enabled=false \ policy.generation.colocated.resources.gpus_per_node=2 \ policy.generation.vllm_cfg.tensor_parallel_size=2 \ checkpointing.enabled=false \ cluster.gpus_per_node=4I tried to rerun this command with all
NCCL_SHM_DISABLE=1removed. I found that:NCCL_SHM_DISABLE=1.NCCL_SHM_DISABLE=1. Total step time: 30.23s (with env) vs. 39.18s (without env)Quick Conclusion
I wasn’t able to reproduce this error for now. Here’s what I plan to do next:
Please feel free to share any suggestions or feedback.
cc: @YUki-666.
yuki-97 commentedon Jul 8, 2025
Thanks @Dazz993 for helping on this!
Actually I met the error when not setting
NCCL_SHM_DISABLEandNCCL_P2P_DISABLE. Can you try if remove these two can reproduce the issue?RL/nemo_rl/models/policy/dtensor_policy_worker.py
Lines 139 to 146 in ae54cbd
RL/nemo_rl/models/generation/vllm.py
Lines 1227 to 1229 in ae54cbd
After removing the env vars, even the following script with 2 GPUs should be ok to reproduce it. (I can reproduce it on 2*A100-SXM4)
uv run python examples/run_grpo_math.py \ policy.generation.colocated.enabled=false \ policy.generation.colocated.resources.gpus_per_node=1 \ policy.generation.vllm_cfg.tensor_parallel_size=1 \ checkpointing.enabled=false \ cluster.gpus_per_node=2yuki-97 commentedon Jul 8, 2025
BTW, I also met the same issue in mcore worker and needs to set the env vars to avoid it in #613.
And I also realized the slowdown in
policy_trainingandpolicy_and_reference_logprobsin both dtensor and mcore worker after setting the env vars.Just some additional info, and I think we should first focus on the issue with dtensor worker.
zhandaz commentedon Jul 8, 2025
Thanks @YUki-666 for your input!
Just to clarify, my point is that
NCCL_SHM_DISABLEis not the key env here. It'sNCCL_P2P_DISABLEthat makes the major difference. For example:NCCL_P2P_DISABLE=1, the training crashes.NCCL_SHM_DISABLE=1, the training could work properly.Similarly, both verl and vllm have reported similar issues, where setting
export NCCL_P2P_DISABLE=1could help to mitigate the hangs or crashes.Oh, BTW, I have only tested within a single node. So maybe
NCCL_SHM_DISABLE=1is needed for multi-node training.zhandaz commentedon Jul 8, 2025
@parthchadha @YUki-666
tl'dr: Don't set
NCCL_CUMEM_ENABLE=0for eitherpolicyandpolicy_generationworkers.Details
I traced the source of the error and here's what I found:
In the non-colocated setup, this code path is executed to initialize the nccl communicators for weight updates. e.g.,
RL/nemo_rl/algorithms/grpo.py
Lines 351 to 361 in a249f3c
This eventually calls the
PyNcclCommunicatorprovided by vllm:RL/nemo_rl/models/generation/vllm_backend.py
Lines 29 to 42 in 099730b
After inspecting the traces and warnings reported by nccl (with
NCCL_DEBUG=TRACE),NCCL version 2.26.2+cuda12.2:transport/p2p.cc:298 NCCL WARN Cuda failure 'invalid argument'. https://github.com/NVIDIA/nccl/blob/v2.26.2-1/src/transport/p2p.cc#L249-L299cudaIpcOpenMemHandle. This code path appears broken in this NCCL version in this situation.ncclCuMemEnableis not enabled.The flag
ncclCuMemEnabledis disabled due to the environment variable override in vLLM. This was originally done to fix the extra memory usage (cosing 1~2 GiB GPU memory with cudagraph+allreduce), but we don't really need to do so (enabling CUMEM is actually better for multi-node NVLink setups).RL/nemo_rl/models/policy/dtensor_policy_worker.py
Lines 384 to 392 in 099730b
In the latest release of vLLM,
0.9.2(https://github.com/vllm-project/vllm/blob/v0.9.2/vllm/env_override.py), the behavior has changed. You can seeNCCL_CUMEM_ENABLEis not overrided if set explicitly. [Misc] Do not override NCCL_CUMEM_ENABLE if set explicitly vllm-project/vllm#19105. The motivation was to support RLHF use cases.I manually removed the
NCCL_CUMEM_ENABLE=0in our codebase and the vLLM packages (just hacking and testing), and the training now runs correctly withoutNCCL_P2P_DISABLE=1.Action Items
NCCL_CUMEM_ENABLE=0from our codebase.vllm>=v0.9.1rc1, we only need to explicitly set theNCCL_CUMEM_ENABLE=1.NCCL_CUMEM_ENABLE=1after vLLM sets it.parthchadha commentedon Jul 8, 2025
Thanks @Dazz993 for the detailed findings! Regarding perf benchmark, you can use grpo with 8b model and compare perf before and after your changes.
yuki-97 commentedon Jul 9, 2025
Thanks very much! @Dazz993
This is my script.
I have already run with c230a4d and be05b13.
Can you run one with the same config w/ your fix? If you haven't cluster or wandb for now, can you give me a branch w/ your fix, so that I can help to run one for check.
This is convergence and time cost in my run. Ideally w/ your fix, we should have the same convergence and time cost with the green one (c230a4d).

https://wandb.ai/nvidia/grpo-dev-yukih-dtensor?nw=21eq3fgdy6x
zhandaz commentedon Jul 9, 2025
Thanks! Will let you know if there is any update.
zhandaz commentedon Jul 10, 2025
Where
We can see that:
The PR is up.
qiaochuz-nv commentedon May 5, 2026
QA RCCA Analysis
RCCA Status: Done
RCCA Category: covered
Test Action: none
Fix PR: #613, #636
Root Cause: fix PR includes upstream test coverage.
Trigger Config: NCCL error when using non-colocated generation and set_model_state_dict apis
Coverage Assessment:
Conclusion: RCCA classification completed for this closed NeMo-RL GitHub issue.
build(deps): bump deep_ep x86_64 pin to 29d31c09 (DeepEP #564 NVSHMEM…