Skip to content

[Testcase Refactoring] Add hw_classification to test_ce_colls - #192764

Closed
songzibo wants to merge 1 commit into
pytorch:mainfrom
songzibo:test-ce-colls-hw-classification
Closed

songzibo wants to merge 1 commit into
pytorch:mainfrom
songzibo:test-ce-colls-hw-classification

Conversation

@songzibo

@songzibo songzibo commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

test/distributed/test_ce_colls.py contains a single TestCase subclass, NCCLCopyEngineCollectives, that was previously unclassified. This PR adds hw_classification = HardwareClassification.CUDA and instantiates it with instantiate_device_type_tests(only_for="cuda").

Changes

  • test/distributed/test_ce_colls.py:
    • Added HardwareClassification to the common_utils import block.
    • Added instantiate_device_type_tests import from common_device_type.
    • Labeled NCCLCopyEngineCollectives with hw_classification = HardwareClassification.CUDA.
    • Added instantiate_device_type_tests(NCCLCopyEngineCollectives, globals(), only_for="cuda") at file end.
    • All test_* methods now accept a device parameter (injected by instantiate_device_type_tests).
    • Replaced self.device property references with torch.device(f"{device}:{self.rank}") in test method bodies.

No test logic or decorators are changed. torch.cuda.current_stream() / torch.cuda.Stream() are kept (only_for="cuda" guarantees CUDA).

Motivation

PR #190991 established the convention that every TestCase subclass must carry a hw_classification attribute. PR #190173 (TEST_LINTER) requires that CUDA classes must use instantiate_device_type_tests with only_for="cuda" and every test method must accept a device parameter.

NCCLCopyEngineCollectives exercises NCCL Copy Engine collectives (NCCL 2.28+, requires_cuda_p2p_access, symm_mem rendezvous), which is CUDA-specific.

Dependencies

None.

Test Plan

  • python -m py_compile test/distributed/test_ce_colls.py passes.
  • lintrunner test/distributed/test_ce_colls.py passes (exit 0).
  • Test count unchanged: 2 def test_* methods.
  • Both test methods accept device parameter.
  • instantiate_device_type_tests(only_for="cuda") added.

cc @fffrog @wjlFlyer @pjyFight @FuDdd @lyriexs666 @jishuangfeng @JamesD18 @JiasenTian

@pytorch-bot

pytorch-bot Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192764

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 1fe0ec5 with merge base 567c801 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Aug 10, 2026
@drisspg
drisspg requested a review from fffrog August 10, 2026 18:37
@drisspg drisspg added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 10, 2026
@songzibo

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: tests/distributed"

@pytorch-bot pytorch-bot Bot added the module: tests/distributed This label covers all test cases within the Distributed sheet. label Aug 17, 2026
@fffrog fffrog moved this to Backlog in PyTorch Test Refactoring Aug 17, 2026
@requires_nccl_version((2, 28), "Need NCCL 2.28+ for CE collectives")
@requires_cuda_p2p_access()
class NCCLCopyEngineCollectives(MultiProcContinuousTest):
hw_classification = HardwareClassification.CUDA

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Current test case use symmetric memory with nccl backend. So it's cuda specific, and the label is right.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Need to use instantiate_device_type_tests to instantiate current class.

@songzibo
songzibo force-pushed the test-ce-colls-hw-classification branch from 5f7ba54 to d6305fe Compare August 19, 2026 08:42
kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Aug 26, 2026
kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Aug 26, 2026

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

CUDA specific class also needs instantiate_device_type_tests and every test cases to have the arg device.

@songzibo
songzibo force-pushed the test-ce-colls-hw-classification branch 2 times, most recently from cfb7166 to 29cd190 Compare August 28, 2026 08:17
@songzibo

Copy link
Copy Markdown
Contributor Author

Thanks @wjlFlyer and @KarhouTam for the review! Addressed in the latest push (29cd190):

  • Added instantiate_device_type_tests(NCCLCopyEngineCollectives, globals(), only_for="cuda") at file end.
  • Both test_* methods (test_ce_allgather, test_ce_alltoall) now accept a device parameter.
  • Replaced self.device property references with torch.device(f"{device}:{self.rank}") in test method bodies.
  • _init now takes device parameter.

torch.cuda.current_stream() / torch.cuda.Stream() are kept since only_for="cuda" guarantees CUDA-only execution.

Comment thread test/distributed/test_ce_colls.py Resolved
@songzibo
songzibo force-pushed the test-ce-colls-hw-classification branch from 29cd190 to 1fe0ec5 Compare August 28, 2026 09:00
Label the NCCLCopyEngineCollectives test class with
hw_classification = HardwareClassification.CUDA and instantiate it with
instantiate_device_type_tests(only_for="cuda").

All test methods now accept a device parameter (injected by
instantiate_device_type_tests). The self.device property-based references
are replaced with torch.device(f"{device}:{self.rank}").

The class exercises NCCL Copy Engine collectives (NCCL 2.28+,
requires_cuda_p2p_access, symm_mem rendezvous, torch.device("cuda")),
which is CUDA-specific, so only_for="cuda" is correct per the TEST_LINTER
rule.

Test Plan:
- python -m py_compile test/distributed/test_ce_colls.py passes.
- lintrunner test/distributed/test_ce_colls.py passes (exit 0).
- Test count unchanged: 2 def test_* methods.
- Both test methods accept device parameter.
- instantiate_device_type_tests(only_for="cuda") added.

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

Thanks.
cc @fffrog

@songzibo

Copy link
Copy Markdown
Contributor Author

Thanks @KarhouTam! You are right — instantiate_device_type_tests passes primary_device (e.g. "cuda:0") to the device arg, so torch.device(f"{device}:{self.rank}") would produce "cuda:0:0" which is wrong.

Fixed in the latest push (1fe0ec5): kept the device parameter in both test_* methods (required by the linter per #190173), but the method bodies now use self.device property (torch.device("cuda", self.rank)) as before. The device arg is intentionally unused.

fffrog
fffrog previously approved these changes Aug 28, 2026

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

SGTM

@fffrog fffrog moved this from Backlog to Ready for Review(Definitive) in PyTorch Test Refactoring Aug 28, 2026
@songzibo

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 31, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • Distributed (wconstab, mrshenli, pritamdamania87, zhaojuanmao, rohan-varma, ...)
  • Metamates (aditvenk, AmesingFlank, amirafzali, angelayi, anshul-si, ...)
  • Greenlight Review Bot (pytorchgreenlight)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, malfet, albanD, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Sep 7, 2026
@fffrog fffrog moved this from Ready for Review(Definitive) to Ready for Merge in PyTorch Test Refactoring Sep 14, 2026
@fffrog fffrog added the module: tests/simple This label covers all the testcase that are very straightforward label Sep 14, 2026
@fffrog
fffrog dismissed their stale review September 14, 2026 02:52

Dismissing my approval to avoid accidental merging. Another maintainer’s approval is still required before merging.

@KarhouTam

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • Distributed (wconstab, mrshenli, pritamdamania87, zhaojuanmao, rohan-varma, ...)
  • Testing (Temporarily used for test refactoring) (fffrog)
  • Metamates (aditvenk, AmesingFlank, angelayi, anshul-si, aorenste, ...)
  • Greenlight Review Bot (pytorchgreenlight)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, malfet, albanD, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@can-gaa-hou can-gaa-hou 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.

overall lgtm minor some small nits

@skip_if_lt_x_gpu(2)
@skip_if_rocm_ver_atleast_multiprocess([7, 14])
def test_ce_allgather(self):
def test_ce_allgather(self, 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.

device is not needed anymore if not used when in cuda only test, please revert it

@skip_if_lt_x_gpu(2)
@skip_if_rocm_ver_atleast_multiprocess([7, 14])
def test_ce_alltoall(self):
def test_ce_alltoall(self, 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.

ditto

@songzibo

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • Distributed (wconstab, mrshenli, pritamdamania87, zhaojuanmao, rohan-varma, ...)
  • Testing (Temporarily used for test refactoring) (fffrog)
  • Metamates (aditvenk, angelayi, anshul-si, aorenste, atalman, ...)
  • Greenlight Review Bot (pytorchgreenlight)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, malfet, albanD, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

self.assertEqual(out2, out_golden)


instantiate_device_type_tests(NCCLCopyEngineCollectives, globals(), only_for="cuda")

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.

I think for this class, purely adding hw label is enough. No need to add device arg and instantiate_device_type_tests for it.

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

SGTM

Remove this file from test_linter_allowlist.json please

@can-gaa-hou

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

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

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: tests/distributed This label covers all test cases within the Distributed sheet. module: tests/simple This label covers all the testcase that are very straightforward open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants