Skip to content

[Test] Add test hardware classification for test classes - #186918

Closed
orangeH25 wants to merge 10 commits into
pytorch:mainfrom
orangeH25:test/classification-1
Closed

orangeH25 wants to merge 10 commits into
pytorch:mainfrom
orangeH25:test/classification-1

Conversation

@orangeH25

@orangeH25 orangeH25 commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces hardware classification for PyTorch test classes.

Tests can now explicitly declare their hardware classification through a hw_classification class attribute, and users can filter which categories of tests to run via --hw-classification.

When --hw-classification is not specified, all existing test discovery and execution paths remain unchanged.


Changes

Hardware classification

Added HardwareClassification with three categories:

  • GENERIC
  • DEVICE_GENERIC
  • CPU, CUDA, XPU, MPS — specific built-in device types

Test filtering

Added --hw-classification support across unittest, pytest, subprocess, parallel, XML, repeat, and run_test.py execution paths. Filtering is implemented through:

  • HardwareClassificationTestLoader
  • HardwareClassificationPytestPlugin
  • _filter_suite_by_hw_classification()

Tests

Added unit tests in test/test_testing.py covering:

  • hardware classification filtering
  • inherited hw classification metadata

Initial rollout

Annotated test classes in test/profiler/test_memory_profiler.py to validate the rollout and provide an initial set of classified tests.


Test Plan

Verified on CUDA

python test/test_testing.py -v -k 'TestHardwareClassifications'

----------------------------------------------------------------------
Ran 4 tests in 0.006s

OK

Validated the feature using hardware classification annotations in test/profiler/test_memory_profiler.py:

(34 total test methods: 20 GENERIC + 14 DEVICE_GENERIC)

Verified:

  • GENERIC runs 20 tests
  • DEVICE_GENERIC runs 14 tests
  • combined GENERIC + DEVICE_GENERIC runs 34 tests
  • unmatched filters run 0 tests

Verified the filter works across the main execution paths:

  • direct unittest execution
  • pytest / --use-pytest
  • python -m pytest
  • run_test.py forwarding
  • repeat mode
  • parallel mode
  • XML output

Commands:

# direct unittest execution
python test/profiler/test_memory_profiler.py --hw-classification GENERIC

# pytest / --use-pytest
python test/profiler/test_memory_profiler.py --use-pytest --hw-classification GENERIC

# python -m pytest
python -m pytest test/profiler/test_memory_profiler.py --hw-classification GENERIC -v

# run_test.py forwarding
python test/run_test.py -i profiler/test_memory_profiler --hw-classification GENERIC

# repeat mode
python test/profiler/test_memory_profiler.py --repeat 2 --hw-classification GENERIC

# parallel mode
python test/profiler/test_memory_profiler.py --run-parallel 2 --hw-classification GENERIC

# XML output
python test/profiler/test_memory_profiler.py --save-xml /tmp/test_xml2 --hw-classification GENERIC

# unmatched filter (0 tests)
python test/profiler/test_memory_profiler.py --hw-classification CUDA

# combined filter (all tests)
python test/profiler/test_memory_profiler.py --hw-classification GENERIC DEVICE_GENERIC

@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 4af7053 with merge base 1c2190b (image):
💚 Looks good so far! There are no failures yet. 💚

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

@fffrog fffrog moved this from Backlog to Ready for Review(Initial) in PyTorch Test Refactoring Jun 12, 2026
Comment thread test/conftest.py Resolved
Comment thread test/conftest.py Resolved
@fffrog
fffrog marked this pull request as ready for review June 12, 2026 04:24
@fffrog
fffrog requested a review from a team as a code owner June 12, 2026 04:24
@fffrog fffrog changed the title [WIP][Test] Add hardware requirement classification for test classes [Test] Add hardware requirement classification for test classes Jun 12, 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, thank you.

@orangeH25
orangeH25 force-pushed the test/classification-1 branch from 4443ddb to f3768cc Compare June 12, 2026 06:56
@KarhouTam KarhouTam added module: testing Issues related to the torch.testing module (not tests) ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Jun 12, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@orangeH25
orangeH25 force-pushed the test/classification-1 branch from 22bced1 to 91ef91f Compare June 12, 2026 09:41
@orangeH25 orangeH25 changed the title [Test] Add hardware requirement classification for test classes [Test] Add test hardware scope classification for test classes Jun 12, 2026
@orangeH25
orangeH25 force-pushed the test/classification-1 branch from 91ef91f to a7dc7b0 Compare June 12, 2026 11:22
@orangeH25 orangeH25 changed the title [Test] Add test hardware scope classification for test classes [Test] Add test hardware classification for test classes Jun 12, 2026
@datadog-pytorch-via-lf

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 1 Pipeline job failed

pull | linux-jammy-py3.14-clang18 / test-osdc (default, 2, 5, mt-l-x86iavx512-16-128)   View in Datadog   GitHub Actions

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a7dc7b0 | Docs | Give us feedback!

mansiag05 added a commit to mansiag05/ai-marketplace that referenced this pull request Jun 24, 2026
New plugin to guide refactoring PyTorch test files for the community
device-agnostic testing initiative (pytorch/pytorch#174469, #185142, #185590).

Plugin structure:
  - skills/test-refactor/SKILL.md: 4-phase workflow (Analyze, Classify, Refactor, Verify)
  - skills/test-refactor/CLASSIFICATION-GUIDE.md: decision tree for 5 hardware categories
    (GENERIC, DEVICE_GENERIC, DEVICE_SPECIFIC, MULTI_DEVICE_GENERIC, MULTI_DEVICE_SPECIFIC)
  - skills/test-refactor/PATTERNS.md: 7 before/after examples from real merged PRs
  - skills/test-refactor/REFERENCES.md: links to RFCs, tracking spreadsheet, Slack, example PRs
  - agents/test-refactor-agent.md: specialist agent with generic delegation to compile agents
    (extensible to distributed, quantization agents as they get added)

Supports the hw_classification attribute from pytorch/pytorch#186918.
Registered in marketplace.json. Updated README.md and REPO_ARCH.md.

@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, thank you for updates.

@fffrog fffrog moved this from Ready for Review(Initial) to Ready for Review(Definitive) in PyTorch Test Refactoring Jun 25, 2026
@fffrog

fffrog commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Hi @albanD, so sorry to bother you again, could you help to review and approve this PR first? This PR is the fundamental one.

@amdfaa

amdfaa commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This PR's MI350 CI jobs are stuck queued because they still request the old linux.rocm.gpu.gfx950.* runner labels. Those labels have been renamed with an amd-do- prefix, so the jobs won't pick up runners until you rebase onto the latest default branch.

See the active SEV for details: #187193

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current 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: testing Issues related to the torch.testing module (not tests) open source topic: not user facing topic category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants