Skip to content

[Test] Move CUDA-specific tests from TestProfiler to TestProfilerCUDA in test_profiler - #182433

Closed
RiyaP2508 wants to merge 6 commits into
gh/RiyaP2508/8/basefrom
gh/RiyaP2508/8/head
Closed

RiyaP2508 wants to merge 6 commits into
gh/RiyaP2508/8/basefrom
gh/RiyaP2508/8/head

Conversation

@RiyaP2508

@RiyaP2508 RiyaP2508 commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

Moved tests: test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method @skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

Test plan

  • Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: @albanD @fffrog @mansiag05

@pytorch-bot

pytorch-bot Bot commented May 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures

As of commit 5c07583 with merge base 019cea9 (image):

NEW FAILURES - The following jobs have failed:

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

Move 9 tests that use CUDA-only APIs (CUDA graphs, multi-GPU, OOM,
FLOPS, cuda_sync, external_correlation, activity_filter dict/mixed/
nonmember/empty) from TestProfiler to TestProfilerCUDA where they
belong under the existing CUDA skip guard.

Add payload() and _check_stats() helper methods to TestProfilerCUDA
since the moved tests depend on them.

No logic changes -- pure code relocation.

[ghstack-poisoned]
@RiyaP2508 RiyaP2508 changed the title [test] Move CUDA-specific tests from TestProfiler to TestProfilerCUDA [Test] Move CUDA-specific tests from TestProfiler to TestProfilerCUDA May 5, 2026
@RiyaP2508 RiyaP2508 changed the title [Test] Move CUDA-specific tests from TestProfiler to TestProfilerCUDA [Test] Move CUDA-specific tests from TestProfiler to TestProfilerCUDA in test_profiler May 5, 2026
@mansiag05 mansiag05 moved this from Backlog to Ready for Review in PyTorch Test Refactoring May 6, 2026
@fffrog fffrog moved this from Ready for Review(Definitive) to Ready for Review(Initial) in PyTorch Test Refactoring May 7, 2026
…rofilerCUDA in test_profiler"


## Summary
Move 9 CUDA-only tests from `TestProfiler` to `TestProfilerCUDA` where they belong under the existing class-level CUDA skip guard.
**Moved tests:**
- test_kineto_multigpu
- test_oom_tracing
- test_flops
- test_profiler_cuda_sync_events
- test_disable_external_correlation
- test_activity_filter_dict_syntax
- test_activity_filter_mixed_syntax
- test_activity_filter_nonmember_type_name
- test_activity_filter_empty_list
Also copies `payload()` and `_check_stats()` helper methods to `TestProfilerCUDA` since the moved tests depend on them.
No logic changes — pure code relocation.
## Test plan
- [x] Verified on CUDA : 110 passed, 2 skipped, 0 failures

CC: albanD fffrog mansiag05 

[ghstack-poisoned]
Comment thread test/profiler/test_profiler.py Outdated
check_trace(fname)

@unittest.skipIf(not kineto_available(), "Kineto is required")
@unittest.skipIf(not torch.cuda.is_available(), "CUDA is required")

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.

duplicated check, we can safely remote this one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

will remove these, thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed in latest push. Thanks!!

Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved

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

@fffrog fffrog moved this from Ready for Review(Initial) to Ready for Review(Definitive) in PyTorch Test Refactoring May 13, 2026
…rofilerCUDA in test_profiler"


## Summary

Move 5 tests that use CUDA-only APIs from `TestProfiler` to `TestProfilerCUDA` where they belong under the existing class-level CUDA skip guard.

**Moved tests:**
- `test_kineto_multigpu` 
- `test_oom_tracing` 
- `test_profiler_cuda_sync_events` 
- `test_disable_external_correlation` 
- `test_activity_filter_mixed_syntax` 

Also copies `payload()` and `_check_stats()` helper methods to `TestProfilerCUDA` since the moved tests depend on them.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: albanD fffrog mansiag05 

[ghstack-poisoned]
@RiyaP2508

Copy link
Copy Markdown
Collaborator Author

SGTM, thank you.

I have updated all suggested changes. Thanks for re-reviewing!

…rofilerCUDA in test_profiler"


## Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

**Moved tests:** test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: albanD fffrog mansiag05 

[ghstack-poisoned]
@RiyaP2508
RiyaP2508 requested review from albanD and jbschlosser May 20, 2026 13:37
@jbschlosser

Copy link
Copy Markdown
Contributor

@claude review this PR and verify that it only moves tests to a CUDA-specific test class; call out any extra changes done beyond simple code movement

@claude

claude Bot commented May 20, 2026 •

Copy link
Copy Markdown

Claude finished @jbschlosser's task in 2m 8s —— View job


Review: Pure code movement verification

  • Examine the full diff between base and HEAD
  • Verify tests were moved without logic changes
  • Check for helper method duplication (payload, _check_stats)
  • Verify removal of redundant @skipIf decorators
  • Identify any changes beyond simple code relocation
  • Post final review

Verdict: This PR is a clean code relocation with no logic changes. Only one file is modified (test/profiler/test_profiler.py).

What was done

  1. 5 tests moved from TestProfiler → TestProfilerCUDA:

    • test_kineto_multigpu
    • test_oom_tracing
    • test_profiler_cuda_sync_events
    • test_disable_external_correlation
    • test_activity_filter_mixed_syntax
  2. Helper methods duplicated into TestProfilerCUDA: payload() and _check_stats() — needed by the moved tests, still present in TestProfiler for other tests that use them.

  3. Redundant @skipIf(not torch.cuda.is_available()) decorators removed from:

    • test_profiler_cuda_sync_events (had @unittest.skipIf(not torch.cuda.is_available(), "CUDA is required"))
    • test_disable_external_correlation (had @unittest.skipIf(not torch.cuda.is_available(), "CUDA is required"))
    • test_activity_filter_mixed_syntax (had @unittest.skipIf(not torch.cuda.is_available(), "requires CUDA"))
    • test_cudagraph_profiling_workaround (already in TestProfilerCUDA, had a redundant per-method skip)

    All correct — TestProfilerCUDA already has @unittest.skipIf(not torch.cuda.is_available(), "CUDA is required") at class level.

Minor observation (non-blocking)

test_oom_tracing (line 295 in the new file) still has an if torch.cuda.is_available(): guard inside the function body. Since the test is now in TestProfilerCUDA which skips the entire class when CUDA is unavailable, this check is always true — effectively dead code. Not harmful, but could be cleaned up for clarity.

Summary

No logic changes, no extra modifications. The net +13 lines are entirely from duplicating the two helper methods into the CUDA class. The PR does exactly what it claims.


@jbschlosser jbschlosser moved this from Ready for Review(Definitive) to Ready for Merge in PyTorch Test Refactoring May 22, 2026
@jbschlosser

Copy link
Copy Markdown
Contributor

tiny nit: remove dead if torch.cuda.is_available() guard in TestProfilerCUDA called out by claude :)

…rofilerCUDA in test_profiler"


## Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

**Moved tests:** test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: albanD fffrog mansiag05 

[ghstack-poisoned]
…rofilerCUDA in test_profiler"


## Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

**Moved tests:** test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: albanD fffrog mansiag05 

[ghstack-poisoned]
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #182434

pytorchmergebot pushed a commit that referenced this pull request Jun 2, 2026
…est_profiler (#182434)

**Summary**
Create TestProfilerDevice class with 20 tests moved from TestProfiler, refactored to be device-agnostic using instantiate_device_type_tests.

**Infrastructure added:**
- get_profiler_activities(device_type) helper that dynamically builds the ProfilerActivity list
- @onlyAccelerator decorator for GPU-required tests
- @OnlyOn(["cpu", "cuda"]) for tests with CUDA-specific assertions
- instantiate_device_type_tests(TestProfilerDevice, globals())

**Moved and refactored tests:**
- test_kineto — @OnlyOn(["cpu", "cuda"]), device-agnostic profiling with CUDA/ROCm kernel checks guarded
- test_memory_profiler — conditional device memory checks
- test_flops — device-agnostic activity list
- test_kineto_profiler_api — multi-backend profiler API
- test_kineto_profiler_multiple_steppers — step tracking across backends
- test_tensorboard_trace_handler — device-agnostic trace export
- test_kineto_profiler_with_environment_variable — @OnlyOn(["cpu", "cuda"]), subprocess self-detects device
- test_event_list — @onlyAccelerator
- test_basic_chrome_trace — device-aware Chrome trace validation
- test_cpu_annotation_overlap — device-agnostic activity list
- test_user_annotation — simple device param
- test_basic_profile — @onlyAccelerator
- test_dynamic_toggle — @onlyAccelerator
- test_forked_process — skips on CUDA/XPU due to fork-after-init
- test_profile_all_threads — @onlyAccelerator
- test_profiler — device-agnostic with PrivateUse1 fallback
- test_activity_filter_dict_syntax — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator
- test_activity_filter_nonmember_type_name — @onlyAccelerator
- test_activity_filter_empty_list — @onlyAccelerator
- test_kineto_kernel_metadata_in_trace — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator

**Note:** test_kineto_profiler_with_environment_variable self-detects the available device in its subprocess script. test_forked_process skips on CUDA/XPU due to fork-after-init restrictions.

**Test plan**
Verified on CUDA: 111 passed, 11 skipped, 0 failures

Pull Request resolved: #182434
Approved by: https://github.com/fffrog, https://github.com/jansel, https://github.com/jbschlosser
ghstack dependencies: #182432, #182433
@github-project-automation github-project-automation Bot moved this from Ready for Merge to Done in PyTorch Test Refactoring Jun 2, 2026
@github-actions
github-actions Bot deleted the gh/RiyaP2508/8/head branch July 3, 2026 03:37
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
… in test_profiler (pytorch#182433)

## Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

**Moved tests:** test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method @skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: @albanD @fffrog @mansiag05
Pull Request resolved: pytorch#182433
Approved by: https://github.com/fffrog, https://github.com/albanD, https://github.com/jbschlosser
ghstack dependencies: pytorch#182432
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…est_profiler (pytorch#182434)

**Summary**
Create TestProfilerDevice class with 20 tests moved from TestProfiler, refactored to be device-agnostic using instantiate_device_type_tests.

**Infrastructure added:**
- get_profiler_activities(device_type) helper that dynamically builds the ProfilerActivity list
- @onlyAccelerator decorator for GPU-required tests
- @OnlyOn(["cpu", "cuda"]) for tests with CUDA-specific assertions
- instantiate_device_type_tests(TestProfilerDevice, globals())

**Moved and refactored tests:**
- test_kineto — @OnlyOn(["cpu", "cuda"]), device-agnostic profiling with CUDA/ROCm kernel checks guarded
- test_memory_profiler — conditional device memory checks
- test_flops — device-agnostic activity list
- test_kineto_profiler_api — multi-backend profiler API
- test_kineto_profiler_multiple_steppers — step tracking across backends
- test_tensorboard_trace_handler — device-agnostic trace export
- test_kineto_profiler_with_environment_variable — @OnlyOn(["cpu", "cuda"]), subprocess self-detects device
- test_event_list — @onlyAccelerator
- test_basic_chrome_trace — device-aware Chrome trace validation
- test_cpu_annotation_overlap — device-agnostic activity list
- test_user_annotation — simple device param
- test_basic_profile — @onlyAccelerator
- test_dynamic_toggle — @onlyAccelerator
- test_forked_process — skips on CUDA/XPU due to fork-after-init
- test_profile_all_threads — @onlyAccelerator
- test_profiler — device-agnostic with PrivateUse1 fallback
- test_activity_filter_dict_syntax — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator
- test_activity_filter_nonmember_type_name — @onlyAccelerator
- test_activity_filter_empty_list — @onlyAccelerator
- test_kineto_kernel_metadata_in_trace — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator

**Note:** test_kineto_profiler_with_environment_variable self-detects the available device in its subprocess script. test_forked_process skips on CUDA/XPU due to fork-after-init restrictions.

**Test plan**
Verified on CUDA: 111 passed, 11 skipped, 0 failures

Pull Request resolved: pytorch#182434
Approved by: https://github.com/fffrog, https://github.com/jansel, https://github.com/jbschlosser
ghstack dependencies: pytorch#182432, pytorch#182433
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
… in test_profiler (pytorch#182433)

## Summary

Move 5 tests that use CUDA-only APIs from TestProfiler to TestProfilerCUDA where they belong under the existing class-level CUDA skip guard.

**Moved tests:** test_kineto_multigpu, test_oom_tracing, test_profiler_cuda_sync_events, test_disable_external_correlation, test_activity_filter_mixed_syntax.

Also copies payload() and _check_stats() helper methods to TestProfilerCUDA since the moved tests depend on them, and removes redundant per-method @skipIf(not torch.cuda.is_available()) decorators that duplicate the class-level guard.

No logic changes - pure code relocation.

## Test plan
- Verified on CUDA: 100 passed, 2 skipped, 0 failures

CC: @albanD @fffrog @mansiag05
Pull Request resolved: pytorch#182433
Approved by: https://github.com/fffrog, https://github.com/albanD, https://github.com/jbschlosser
ghstack dependencies: pytorch#182432
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…est_profiler (pytorch#182434)

**Summary**
Create TestProfilerDevice class with 20 tests moved from TestProfiler, refactored to be device-agnostic using instantiate_device_type_tests.

**Infrastructure added:**
- get_profiler_activities(device_type) helper that dynamically builds the ProfilerActivity list
- @onlyAccelerator decorator for GPU-required tests
- @OnlyOn(["cpu", "cuda"]) for tests with CUDA-specific assertions
- instantiate_device_type_tests(TestProfilerDevice, globals())

**Moved and refactored tests:**
- test_kineto — @OnlyOn(["cpu", "cuda"]), device-agnostic profiling with CUDA/ROCm kernel checks guarded
- test_memory_profiler — conditional device memory checks
- test_flops — device-agnostic activity list
- test_kineto_profiler_api — multi-backend profiler API
- test_kineto_profiler_multiple_steppers — step tracking across backends
- test_tensorboard_trace_handler — device-agnostic trace export
- test_kineto_profiler_with_environment_variable — @OnlyOn(["cpu", "cuda"]), subprocess self-detects device
- test_event_list — @onlyAccelerator
- test_basic_chrome_trace — device-aware Chrome trace validation
- test_cpu_annotation_overlap — device-agnostic activity list
- test_user_annotation — simple device param
- test_basic_profile — @onlyAccelerator
- test_dynamic_toggle — @onlyAccelerator
- test_forked_process — skips on CUDA/XPU due to fork-after-init
- test_profile_all_threads — @onlyAccelerator
- test_profiler — device-agnostic with PrivateUse1 fallback
- test_activity_filter_dict_syntax — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator
- test_activity_filter_nonmember_type_name — @onlyAccelerator
- test_activity_filter_empty_list — @onlyAccelerator
- test_kineto_kernel_metadata_in_trace — @OnlyOn(["cpu", "cuda"]), @onlyAccelerator

**Note:** test_kineto_profiler_with_environment_variable self-detects the available device in its subprocess script. test_forked_process skips on CUDA/XPU due to fork-after-init restrictions.

**Test plan**
Verified on CUDA: 111 passed, 11 skipped, 0 failures

Pull Request resolved: pytorch#182434
Approved by: https://github.com/fffrog, https://github.com/jansel, https://github.com/jbschlosser
ghstack dependencies: pytorch#182432, pytorch#182433
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants