Skip to content

[Test] Refactor test/functorch/test_leaf_function.py and add hardware classification - #193950

Closed
tszulist-hbn wants to merge 1 commit into
pytorch:mainfrom
tszulist-hbn:test-leaf-function-hw-classification
Closed

tszulist-hbn wants to merge 1 commit into
pytorch:mainfrom
tszulist-hbn:test-leaf-function-hw-classification

Conversation

@tszulist-hbn

Copy link
Copy Markdown
Contributor

Summary

Tag the test classes in test/functorch/test_leaf_function.py as GENERIC so CI can route them via --hw-classification. These are Dynamo/AOTAutograd framework tests: every tensor is on CPU, no class requires an accelerator, and the file intentionally does not use instantiate_device_type_tests (its dtype coverage comes from @parametrize). No runtime behavior is changed -- without the flag, discovery and execution are identical.

Changes

Import HardwareClassification and set hw_classification = GENERIC on TestLeafFunctionMakeFx, TestLeafFunctionAotFunction, TestLeafFunctionEscapedGradients, TestLeafFunctionMakeFxAndCompile, TestLeafFunctionDynamo, TestLeafFunctionRegisterHook and TestLeafFunctionGradDtype.

Test Plan

python test/functorch/test_leaf_function.py
# Ran 103 tests -> OK (skipped=1), unchanged from before

python test/functorch/test_leaf_function.py --hw-classification GENERIC
# Ran 103 tests -> OK (skipped=1)
# HW classification mode active (['GENERIC']): total=103, passed=103, unclassified=0, mismatched=0

python test/functorch/test_leaf_function.py --hw-classification ACCELERATOR
# NO TESTS RAN, mismatched=103

Part of #142029.

@pytorch-bot

pytorch-bot Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - Ready for human review:

Adds hw_classification = HardwareClassification.GENERIC to all seven TestCase
classes in test/functorch/test_leaf_function.py. This matches the established
pattern, the tests are device-agnostic and CPU-only, and behavior is unchanged
when --hw-classification is not passed. No problems found.

Reviewed commit: 2a5cff8

Review run

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2a5cff8 with merge base e7039c1 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pbielak
pbielak requested a review from etaf August 26, 2026 08:27
@pbielak pbielak added ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks ci-no-td Do not run TD on this PR labels Aug 26, 2026
@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased test-leaf-function-hw-classification onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout test-leaf-function-hw-classification && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the test-leaf-function-hw-classification branch from 17337b0 to 2a9814e Compare August 26, 2026 17:14
@pytorch-bot

pytorch-bot Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

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

@tszulist-hbn
tszulist-hbn marked this pull request as ready for review August 30, 2026 21:13
@pbielak
pbielak requested a review from jansel August 31, 2026 07:48
@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

… classification

## Summary

Tag the test classes in `test/functorch/test_leaf_function.py` as `GENERIC` so
CI can route them via `--hw-classification`. These are Dynamo/AOTAutograd
framework tests: every tensor is on CPU, no class requires an accelerator, and
the file intentionally does not use `instantiate_device_type_tests` (its dtype
coverage comes from `@parametrize`). No runtime behavior is changed -- without
the flag, discovery and execution are identical.

## Changes

Import `HardwareClassification` and set `hw_classification = GENERIC` on
`TestLeafFunctionMakeFx`, `TestLeafFunctionAotFunction`,
`TestLeafFunctionEscapedGradients`, `TestLeafFunctionMakeFxAndCompile`,
`TestLeafFunctionDynamo`, `TestLeafFunctionRegisterHook` and
`TestLeafFunctionGradDtype`.

## Test Plan

```bash
python test/functorch/test_leaf_function.py
# Ran 103 tests -> OK (skipped=1), unchanged from before

python test/functorch/test_leaf_function.py --hw-classification GENERIC
# Ran 103 tests -> OK (skipped=1)
# HW classification mode active (['GENERIC']): total=103, passed=103, unclassified=0, mismatched=0

python test/functorch/test_leaf_function.py --hw-classification ACCELERATOR
# NO TESTS RAN, mismatched=103
```

## Notes

The existing `@skipIfXpu` on `test_leaf_function_closure_constants_without_grad`
is kept as-is: the test passes on a local XPU device, but the goldens encode an
accelerator-dependent `nn_module_index`, so dropping the skip is deferred until
XPU CI confirms it. `GENERIC` is still the correct tag -- the classes run on
CPU and none requires an accelerator; the skip is a per-test exclusion.

Part of pytorch#142029.

This change was authored with the assistance of an AI coding agent.
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased test-leaf-function-hw-classification onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout test-leaf-function-hw-classification && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the test-leaf-function-hw-classification branch from 2a9814e to 2a5cff8 Compare August 31, 2026 08:26
@jansel jansel added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 7, 2026
@github-actions github-actions Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Oct 7, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of 2a5cff8: nothing blocking; ready for human review.

Adds hw_classification = HardwareClassification.GENERIC to all seven TestCase classes in test/functorch/test_leaf_function.py. This matches the established pattern, the tests are device-agnostic and CPU-only, and behavior is unchanged when --hw-classification is not passed. No problems found.

This review is AI-generated and advisory. Each new automated review replaces the previous one.

@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@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

cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
… classification (pytorch#193950)

## Summary

Tag the test classes in `test/functorch/test_leaf_function.py` as `GENERIC` so CI can route them via `--hw-classification`. These are Dynamo/AOTAutograd framework tests: every tensor is on CPU, no class requires an accelerator, and the file intentionally does not use `instantiate_device_type_tests` (its dtype coverage comes from `@parametrize`). No runtime behavior is changed -- without the flag, discovery and execution are identical.

## Changes

Import `HardwareClassification` and set `hw_classification = GENERIC` on `TestLeafFunctionMakeFx`, `TestLeafFunctionAotFunction`, `TestLeafFunctionEscapedGradients`, `TestLeafFunctionMakeFxAndCompile`, `TestLeafFunctionDynamo`, `TestLeafFunctionRegisterHook` and `TestLeafFunctionGradDtype`.

## Test Plan

```bash
python test/functorch/test_leaf_function.py
# Ran 103 tests -> OK (skipped=1), unchanged from before

python test/functorch/test_leaf_function.py --hw-classification GENERIC
# Ran 103 tests -> OK (skipped=1)
# HW classification mode active (['GENERIC']): total=103, passed=103, unclassified=0, mismatched=0

python test/functorch/test_leaf_function.py --hw-classification ACCELERATOR
# NO TESTS RAN, mismatched=103
```

Part of pytorch#142029.
Pull Request resolved: pytorch#193950
Approved by: https://github.com/pbielak, https://github.com/etaf, https://github.com/jansel
torchxpubot pushed a commit to intel/torch-xpu-ops that referenced this pull request Oct 15, 2026
)

Next PR for synchronizing upstream generalization with local files:

1) **functorch/test_eager_transforms.py**

Upstream PR: pytorch/pytorch#192806

Before: 682 passed, 7 skipped, 2 xfailed
After:  721 passed, 6 skipped, 2 xfailed

Changes:
- 11 new test cases: `TestGradTransform::test_inference_mode_*`
- 4 new test cases: `TestCompileTransforms::test_compile_dynamic_grad_*`
- 2 new test cases:
`TestGradTransform::test_pop_dynamic_layer_stack_to_depth_*`
- 2 new test cases: `TestFunctionalize::test_multioutput_view_*`
- new test case: `TestGradTransform::test_linear_nd_inplace_activation`
- new test case: `TestAutogradFunction::test_unwrap_dead_wrappers`
- 1 less skipped: `test_unrelated_hessian` now passes on XPU
- `TestGradTrackingTensorToList` is no longer device-parametrized: the
local
copy ran its 4 device-agnostic test cases twice (CPU and XPU), upstream
marks
  the class `GENERIC` and runs them once
- the 15 device-parametrized classes are renamed to `Test*Device`


2) **functorch/test_leaf_function.py**

Upstream PR: pytorch/pytorch#193950

Before: not run
After:  102 passed, 1 skipped


3) **export/test_passes.py**

Upstream PR: pytorch/pytorch#196974

Before: 25 passed, 2 xfailed
After:  26 passed, 4 skipped, 2 xfailed

Changes:
- 5 new test cases: `TestMoveToDevicePassCuda`, 4 require CUDA and are
skipped,
  `test_move_to_device_pass_interpreter_only_graph` passes
- move `test_move_device_example_inputs`, `test_move_device_submod`,
`test_move_device_to` and `test_move_to_device_pass` from `TestPasses`
to the
  new device-parametrized `TestMoveToDevicePassDevice`

4) **export/test_converter.py**

Upstream PR: pytorch/pytorch#197113

Before: 46 passed, 2 skipped
After:  46 passed, 2 skipped

Changes:
- move `test_prim_device` from `TestConverter` to the new
device-parametrized
`TestConverterDevice`, which runs it on both CPU and XPU. The local copy
carried it as `test_prim_device_cuda` with a hardcoded `device="xpu:0"`,
  so a single misnamed test case becomes two properly parametrized ones
minmingzhu pushed a commit to minmingzhu/torch-xpu-ops that referenced this pull request Oct 28, 2026
…tel#5693)

Next PR for synchronizing upstream generalization with local files:

1) **functorch/test_eager_transforms.py**

Upstream PR: pytorch/pytorch#192806

Before: 682 passed, 7 skipped, 2 xfailed
After:  721 passed, 6 skipped, 2 xfailed

Changes:
- 11 new test cases: `TestGradTransform::test_inference_mode_*`
- 4 new test cases: `TestCompileTransforms::test_compile_dynamic_grad_*`
- 2 new test cases:
`TestGradTransform::test_pop_dynamic_layer_stack_to_depth_*`
- 2 new test cases: `TestFunctionalize::test_multioutput_view_*`
- new test case: `TestGradTransform::test_linear_nd_inplace_activation`
- new test case: `TestAutogradFunction::test_unwrap_dead_wrappers`
- 1 less skipped: `test_unrelated_hessian` now passes on XPU
- `TestGradTrackingTensorToList` is no longer device-parametrized: the
local
copy ran its 4 device-agnostic test cases twice (CPU and XPU), upstream
marks
  the class `GENERIC` and runs them once
- the 15 device-parametrized classes are renamed to `Test*Device`


2) **functorch/test_leaf_function.py**

Upstream PR: pytorch/pytorch#193950

Before: not run
After:  102 passed, 1 skipped


3) **export/test_passes.py**

Upstream PR: pytorch/pytorch#196974

Before: 25 passed, 2 xfailed
After:  26 passed, 4 skipped, 2 xfailed

Changes:
- 5 new test cases: `TestMoveToDevicePassCuda`, 4 require CUDA and are
skipped,
  `test_move_to_device_pass_interpreter_only_graph` passes
- move `test_move_device_example_inputs`, `test_move_device_submod`,
`test_move_device_to` and `test_move_to_device_pass` from `TestPasses`
to the
  new device-parametrized `TestMoveToDevicePassDevice`

4) **export/test_converter.py**

Upstream PR: pytorch/pytorch#197113

Before: 46 passed, 2 skipped
After:  46 passed, 2 skipped

Changes:
- move `test_prim_device` from `TestConverter` to the new
device-parametrized
`TestConverterDevice`, which runs it on both CPU and XPU. The local copy
carried it as `test_prim_device_cuda` with a hardcoded `device="xpu:0"`,
  so a single misnamed test case becomes two properly parametrized ones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged open source ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

Status: Aged Pending Review

Development

Successfully merging this pull request may close these issues.

6 participants