Skip to content

[PyTorch] Distributed tests set device in NCCL init and manually shut down NCCL - #3655

Open
timmoon10 wants to merge 4 commits into
NVIDIA:mainfrom
timmoon10:tmoon/debug-dist-tests
Open

timmoon10 wants to merge 4 commits into
NVIDIA:mainfrom
timmoon10:tmoon/debug-dist-tests

Conversation

@timmoon10

Copy link
Copy Markdown
Member

Description

This attempts to debug NCCL errors in some distributed tests.

#3654 also manually tears down NCCL in the TE ops distributed test.

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

  • Set device in NCCL init in distributed tests.
  • Manually tear down NCCL in TE ops distributed test.

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

@timmoon10
timmoon10 requested a review from vthumbe1503 October 8, 2026 18:44
@timmoon10 timmoon10 added the testing Improvements to tests or testing infrastructure label Oct 8, 2026
@timmoon10

Copy link
Copy Markdown
Member Author

/te-ci pytorch L1

Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
@timmoon10
timmoon10 marked this pull request as ready for review October 9, 2026 02:14
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the previous cleanup issue is fixed and no new blocking issue was found.

Summary

This PR gives NCCL an explicit CUDA device in two distributed tests and adds explicit cleanup to the fusible-ops test.

  • The latest change moves the final barrier and CUDA synchronization onto the success path.
  • Group destruction remains in finally, including when a test raises.
  • The previous cleanup finding is fixed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "Apply suggestion from @timmoon10" · Reviewed by Greptile

Comment thread tests/pytorch/distributed/test_fusible_ops.py
Comment thread tests/pytorch/distributed/test_fusible_ops.py
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
@timmoon10

Copy link
Copy Markdown
Member Author

/te-ci pytorch L1

init_method=f"file://{init_file}",
rank=rank,
world_size=world_size,
device_id=device,

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.

Would be good to understand why device_id needs to be set manually.

@timmoon10 and I had offline discussion regarding this. It might be because this particular test doesnt use torchrun like other tests do, and so the device is not auto-set to "cuda:rank" like other tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do actually have a diff already that changes this test to torchrun to avoid this. Can make PR today. @timmoon10

@vthumbe1503 vthumbe1503 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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Improvements to tests or testing infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants