Skip to content

[cherry-pick][release/2.13] fix(distributed): subgroup NCCL regression + nccl_utils TRT 11 cleanup (#4407)#4408

Merged
lanluo-nvidia merged 2 commits into
release/2.13from
cherrypick_4407
Jul 15, 2026
Merged

[cherry-pick][release/2.13] fix(distributed): subgroup NCCL regression + nccl_utils TRT 11 cleanup (#4407)#4408
lanluo-nvidia merged 2 commits into
release/2.13from
cherrypick_4407

Conversation

@apbose

@apbose apbose commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick of #4407 onto release/2.13. Applied cleanly (single commit, no conflicts); _nccl_utils.py and test_native_nccl.py are byte-identical to #4407's head.

What it does:

  • Fixes the subgroup NCCL regression (test_distributed_mode_subgroup, test_distributed_mode_context_switch) introduced by Python runtime rework  #4222 (Python runtime rework): adds dist.barrier(group=subgroup) before the first TRT forward so PyTorch's lazy ncclComm_t is initialized and bind_nccl_comm() sees a non-zero getCommPtr().
  • Removes use_python_runtime=True (deprecated no-op in 2.13); collapses the python-runtime-only multirank variants to cpp-only.
  • Fixes _multirank_scatter/gather_correctness dispatch in run_multirank_tests() (broken since TRT 11 MD Ops #4321).
  • Adds _cpp_runtime_available() guard to TestPythonRuntimePickle.
  • nccl_utils TRT 11 cleanup: setup_nccl_for_torch_tensorrt() drops the ensure_nccl_symlink() call and pre-loads libnccl.so.2 directly. TRT 11.0+ (ncclWrapper.cpp) dlopens libnccl.so.2 first, matching PyTorch's soname, so glibc reuses the already-loaded handle — no symlink needed. ensure_nccl_symlink() retained for TRT < 11.0.

Original PR: #4407

🤖 Generated with Claude Code

test_native_nccl.py:
- Fix test_distributed_mode_subgroup and test_distributed_mode_context_switch
  regressions introduced by PR #4222 (Python runtime rework): add
  dist.barrier(group=subgroup) before first TRT forward so PyTorch's lazy
  ncclComm_t is initialized and bind_nccl_comm() sees a non-zero getCommPtr().
- Remove all use_python_runtime=True flags (deprecated no-op in 2.13).
- Add _cpp_runtime_available() guard to TestPythonRuntimePickle so it skips
  in C++ builds where _TRTEngine's custom op is never registered.
- Fix _multirank_scatter_correctness / _multirank_gather_correctness in
  run_multirank_tests(): wrap with lambdas that loop over root ranks to match
  their (root, rank, world_size, device) signature (broken since PR #4321).
- Remove _multirank_distributed_mode_subgroup_python and
  _multirank_distributed_mode_context_switch_python (cannot work when C++
  extension is loaded); collapse _multirank_pg_migration to cpp-only.

_nccl_utils.py:
- setup_nccl_for_torch_tensorrt(): drop ensure_nccl_symlink() call and
  pre-load libnccl.so.2 directly instead of via the unversioned symlink.
  TRT 11.0+ (ncclWrapper.cpp) tries dlopen("libnccl.so.2") first, matching
  PyTorch's soname exactly; glibc reuses the already-loaded handle so no
  symlink is needed. ensure_nccl_symlink() is kept for TRT < 11.0 users.
- Update module docstring to reflect confirmed TRT 11.0+ behavior.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@lanluo-nvidia lanluo-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lanluo-nvidia
lanluo-nvidia merged commit 16d94f3 into release/2.13 Jul 15, 2026
158 of 176 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed component: api [Python] Issues re: Python API component: tests Issues re: Tests Force All Tests[L0+L1+L2] For run all the L0, L1, L2 tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants