pytorch - ✅(Solved) Fix [OpenReg] Add testing operator framework usage examples [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#177268Fetched 2026-04-08 00:42:22
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
labeled ×5added_to_project_v2 ×1mentioned ×1project_v2_item_status_changed ×1

PR fix notes

PR #176264: [Test] Add device type test support for op decorators and skips in DeviceTypeTestBase

Description (problem / solution / changelog)

Summary

This pull request enhances the device type test infrastructure to allow device-specific decorators and skips for operator tests, and demonstrates this with a new test for the Open Registration (PrivateUse1) extension. The main improvements are the introduction of op_decorators and op_skips hooks, and a new test file that exercises these features for custom backend scenarios.

Device-specific test customization:

  • Added op_decorators and op_skips class attributes to DeviceTypeTestBase, enabling device-specific decorators (like expectedFailure) and skips to be applied to operator tests.
  • Implemented update_op_list class method to apply these decorators and skips to the relevant operator tests, handling device type mapping (including custom backends like PrivateUse1).
  • Integrated update_op_list into the test parametrization process to ensure operator test configurations are updated before test instantiation.

Testing and demonstration:

  • Added a new test file test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_testing.py that demonstrates the use of op_decorators and op_skips for custom backend operator tests, including examples with dummy ops and expected failure/skipped tests.
(pytorch-dev-cuda) ➜  pytorch-cuda git:(testing/op-filter) ✗ python test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_testing.py --verbose
test_normal_openreg (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_normal_openreg) ... ok
test_op_dummy_op1_openreg_bfloat16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_bfloat16) ... ok
test_op_dummy_op1_openreg_bool (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_bool) ... ok
test_op_dummy_op1_openreg_complex128 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_complex128) ... ok
test_op_dummy_op1_openreg_complex64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_complex64) ... ok
test_op_dummy_op1_openreg_float16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_float16) ... ok
test_op_dummy_op1_openreg_float32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_float32) ... ok
test_op_dummy_op1_openreg_float64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_float64) ... ok
test_op_dummy_op1_openreg_int16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_int16) ... ok
test_op_dummy_op1_openreg_int32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_int32) ... ok
test_op_dummy_op1_openreg_int64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_int64) ... ok
test_op_dummy_op1_openreg_int8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_int8) ... ok
test_op_dummy_op1_openreg_uint8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op1_openreg_uint8) ... ok
test_op_dummy_op2_openreg_bfloat16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_bfloat16) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_bool (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_bool) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_complex128 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_complex128) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_complex64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_complex64) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_float16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_float16) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_float32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_float32) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_float64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_float64) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_int16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_int16) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_int32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_int32) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_int64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_int64) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_int8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_int8) ... skipped 'skip dummy_op2'
test_op_dummy_op2_openreg_uint8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op2_openreg_uint8) ... skipped 'skip dummy_op2'
test_op_dummy_op3_openreg_bfloat16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_bfloat16) ... expected failure
test_op_dummy_op3_openreg_bool (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_bool) ... expected failure
test_op_dummy_op3_openreg_complex128 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_complex128) ... expected failure
test_op_dummy_op3_openreg_complex64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_complex64) ... expected failure
test_op_dummy_op3_openreg_float16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_float16) ... expected failure
test_op_dummy_op3_openreg_float32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_float32) ... expected failure
test_op_dummy_op3_openreg_float64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_float64) ... expected failure
test_op_dummy_op3_openreg_int16 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_int16) ... expected failure
test_op_dummy_op3_openreg_int32 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_int32) ... expected failure
test_op_dummy_op3_openreg_int64 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_int64) ... expected failure
test_op_dummy_op3_openreg_int8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_int8) ... expected failure
test_op_dummy_op3_openreg_uint8 (__main__.TestDeviceTypeOpenRegPRIVATEUSE1.test_op_dummy_op3_openreg_uint8) ... expected failure

----------------------------------------------------------------------
Ran 37 tests in 0.281s

OK (skipped=12, expected failures=12)

Changed files

  • test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_testing.py (added, +50/-0)
  • torch/testing/_internal/common_device_type.py (modified, +32/-0)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Refactoring for operator testing framework (RFC, Draft PR) is underway. This issue will be used to track addition of its usage (YAML interface) in openreg.

cc @mruberry

extent analysis

Fix Plan

To add the usage of the operator testing framework's YAML interface in OpenReg, we need to make the following changes:

  • Update the OpenReg configuration to include the YAML interface
  • Implement the necessary code to parse and execute the YAML files

Example Code

Here's an example of how you can implement this:

import yaml

# Load the YAML file
with open('operator_test.yaml', 'r') as f:
    config = yaml.safe_load(f)

# Execute the tests based on the YAML config
for test in config['tests']:
    # Run the test
    print(f"Running test: {test['name']}")
    # Implement the test execution logic here

You'll also need to update the OpenReg configuration to include the YAML interface. This can be done by adding a new section to the configuration file:

operator_testing:
  yaml_interface:
    enabled: true
    config_file: operator_test.yaml

Verification

To verify that the fix worked, you can run the tests using the YAML interface and check that they execute correctly. You can also add logging or debugging statements to ensure that the YAML file is being parsed and executed as expected.

Extra Tips

  • Make sure to handle any errors that may occur when parsing or executing the YAML file
  • Consider adding support for multiple YAML files or configurations
  • Use a consistent naming convention for the YAML files and configurations to avoid confusion.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING