pytorch - ✅(Solved) Fix Add ability for out-of-treee backend to register supported_ops when reusing PyTorch tests suite [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#178516Fetched 2026-04-08 01:35:52
View on GitHub
Comments
0
Participants
1
Timeline
11
Reactions
5
Participants
Timeline (top)
labeled ×4subscribed ×2added_to_project_v2 ×1cross-referenced ×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.

Changed files

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

🚀 The feature, motivation and pitch

Filing this issue to track (note it's not actionable)

As a nice-to-have follow up to https://github.com/pytorch/pytorch/issues/177256, a backend should also be able to register its supported ops.

As discussed here https://github.com/torch-spyre/torch-spyre/pull/1135#discussion_r2962151261 this can be a "nice-to-have" for a less mature backend which might start off with only a few ops implemented

This is lower priority compared to the skip mechanism in https://github.com/pytorch/pytorch/issues/177256

Alternatives

No response

Additional context

No response

cc @mruberry

extent analysis

Fix Plan

To register supported ops for a backend, we need to implement the following steps:

  • Define a function to register the ops
  • Create a dictionary to store the supported ops
  • Iterate over the ops and register them

Example Code

# Define a function to register the ops
def register_ops(backend):
    supported_ops = {}
    # Iterate over the ops and register them
    for op in backend.get_supported_ops():
        supported_ops[op.name] = op
    return supported_ops

# Example usage:
class Backend:
    def get_supported_ops(self):
        # Return a list of supported ops
        return [Op1, Op2, Op3]

class Op:
    def __init__(self, name):
        self.name = name

# Register the ops
backend = Backend()
supported_ops = register_ops(backend)
print(supported_ops)

Verification

To verify that the fix worked, you can:

  • Check the supported_ops dictionary to ensure it contains the expected ops
  • Test the backend with the registered ops to ensure they are working correctly

Extra Tips

  • Make sure to handle any errors that may occur during the registration process
  • Consider adding logging or debugging statements to help diagnose any issues that may arise.

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

pytorch - ✅(Solved) Fix Add ability for out-of-treee backend to register supported_ops when reusing PyTorch tests suite [1 pull requests, 1 participants]