-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Add linter to register schema upgraders for torch_call_dispatcher #166997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mikaylagawarecki
wants to merge
6
commits into
gh/mikaylagawarecki/364/base
Choose a base branch
from
gh/mikaylagawarecki/364/head
base: gh/mikaylagawarecki/364/base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add linter to register schema upgraders for torch_call_dispatcher #166997
mikaylagawarecki
wants to merge
6
commits into
gh/mikaylagawarecki/364/base
from
gh/mikaylagawarecki/364/head
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ghstack-poisoned]
This was referenced Nov 4, 2025
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/166997
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 9cda7d6 with merge base 77b9399 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…patcher"
**This is a first step to remind users to add schema_adapters. A second step will be to figure out the testing framework.**
This PR adds two linters
1) STABLE_NATIVE_OPS_LIST
Parses a list of ops that are called via `torch_call_dispatcher` in `torch/csrc/stable/ops.h` and prompts user to add missing ops to `torch/csrc/stable/native_ops.txt`
### Examples
1. Remove aten::zero from stable/native_ops.txt
```
Error (STABLE_NATIVE_OPS_LIST) missing-native-ops
The following ATen ops are called in ops.h but not documented in
native_ops.txt:
- aten::zero_
```
2) STABLE_NATIVE_FUNCTION_SCHEMA
Using `torch/csrc/stable/native_ops.txt`, checks whether any of the functions in questions had their schemas modified in native_functions.yaml and prompts the user to register an adapter if so.
## Examples
1. modifying the signature of `clone` to `- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> Tensor`
```
>>> Lint for aten/src/ATen/native/native_functions.yaml:
Error (STABLE_NATIVE_FUNCTION_SCHEMA) missing-schema-adapter
Schema change detected for 'clone' which is used in torch/csrc/stable/
ops.h:
Old schema:
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
New schema:
clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True)
-> Tensor
Please register a schema adapter in torch/csrc/shim_common.cpp
in the _register_adapters() function to handle this schema change.
See #165284 for an example.
```
Registering something in _register_adapters in shim_common.cpp makes this go away
[ghstack-poisoned]
…patcher"
**This is a first step to remind users to add schema_adapters. A second step will be to figure out the testing framework.**
This PR adds two linters
1) STABLE_NATIVE_OPS_LIST
Parses a list of ops that are called via `torch_call_dispatcher` in `torch/csrc/stable/ops.h` and prompts user to add missing ops to `torch/csrc/stable/native_ops.txt`
##### Examples
1. Remove aten::zero from stable/native_ops.txt
```
Error (STABLE_NATIVE_OPS_LIST) missing-native-ops
The following ATen ops are called in ops.h but not documented in
native_ops.txt:
- aten::zero_
```
2) STABLE_NATIVE_FUNCTION_SCHEMA
Using `torch/csrc/stable/native_ops.txt`, checks whether any of the functions in questions had their schemas modified in native_functions.yaml and prompts the user to register an adapter if so.
##### Examples
1. modifying the signature of `clone` to `- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> Tensor`
```
>>> Lint for aten/src/ATen/native/native_functions.yaml:
Error (STABLE_NATIVE_FUNCTION_SCHEMA) missing-schema-adapter
Schema change detected for 'clone' which is used in torch/csrc/stable/
ops.h:
Old schema:
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
New schema:
clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True)
-> Tensor
Please register a schema adapter in torch/csrc/shim_common.cpp
in the _register_adapters() function to handle this schema change.
See #165284 for an example.
```
Registering something in _register_adapters in shim_common.cpp makes this go away
[ghstack-poisoned]
…patcher"
**This is a first step to remind users to add schema_adapters. A second step will be to figure out the testing framework.**
This PR adds two linters
1) STABLE_NATIVE_OPS_LIST
Parses a list of ops that are called via `torch_call_dispatcher` in `torch/csrc/stable/ops.h` and prompts user to add missing ops to `torch/csrc/stable/native_ops.txt`
##### Examples
1. Remove aten::zero from stable/native_ops.txt
```
Error (STABLE_NATIVE_OPS_LIST) missing-native-ops
The following ATen ops are called in ops.h but not documented in
native_ops.txt:
- aten::zero_
```
2) STABLE_NATIVE_FUNCTION_SCHEMA
Using `torch/csrc/stable/native_ops.txt`, checks whether any of the functions in questions had their schemas modified in native_functions.yaml and prompts the user to register an adapter if so.
##### Examples
1. modifying the signature of `clone` to `- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> Tensor`
```
>>> Lint for aten/src/ATen/native/native_functions.yaml:
Error (STABLE_NATIVE_FUNCTION_SCHEMA) missing-schema-adapter
Schema change detected for 'clone' which is used in torch/csrc/stable/
ops.h:
Old schema:
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
New schema:
clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True)
-> Tensor
Please register a schema adapter in torch/csrc/shim_common.cpp
in the _register_adapters() function to handle this schema change.
See #165284 for an example.
```
Registering something in _register_adapters in shim_common.cpp makes this go away
[ghstack-poisoned]
…patcher"
**This is a first step to remind users to add schema_adapters. A second step will be to figure out the testing framework.**
This PR the linter STABLE_NATIVE_FUNCTION_SCHEMA
Which
1. Parses `torch/csrc/stable/ops.h` for functions called via `torch_call_dispatcher` and populates these in `torch/csrc/stable/native_ops.txt`
2. Using `torch/csrc/stable/native_ops.txt`, checks whether any of the functions in questions had their schemas modified in native_functions.yaml and
a. Checks if the change was the value of the default for an argument changing --> WARNING for user to update ops.h (this will be properly enforced by the testing framework).
b. Checks whether the change warrants an adapter registration --> ERROR unless the user registers an adapter for the appropriate version in torch/csrc/shim_common.cpp (this will be properly tested by the testing framework)
##### Examples
1. modifying the signature of `clone` to `- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> Tensor`
```
>>> Lint for aten/src/ATen/native/native_functions.yaml:
Error (STABLE_NATIVE_FUNCTION_SCHEMA) missing-schema-adapter
Schema change detected for 'clone' which is used in torch/csrc/stable/
ops.h:
Old schema:
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
New schema:
clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True)
-> Tensor
Please register a schema adapter in torch/csrc/shim_common.cpp
in the _register_adapters() function to handle this schema change.
See #165284 for an example.
```
Registering something in _register_adapters in shim_common.cpp with the correct version makes this lint error go away
[ghstack-poisoned]
…patcher"
**This is a first step to remind users to add schema_adapters. A second step will be the testing framework.**
This PR adds the linter STABLE_NATIVE_FUNCTION_SCHEMA
Which
1. Parses `torch/csrc/stable/ops.h` for functions called via `torch_call_dispatcher` and populates these in `torch/csrc/stable/native_ops.txt`
2. Using `torch/csrc/stable/native_ops.txt`, checks whether any of the functions in questions had their schemas modified in native_functions.yaml and
a. Checks if the change was the value of the default for an argument changing --> WARNING for user to update ops.h (this will be properly enforced by the testing framework).
b. Checks whether the change warrants an adapter registration --> ERROR unless the user registers an adapter for the appropriate version in torch/csrc/shim_common.cpp (this will be properly tested by the testing framework)
##### Examples
1. modifying the signature of `clone` to `- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> Tensor`
```
>>> Lint for aten/src/ATen/native/native_functions.yaml:
Error (STABLE_NATIVE_FUNCTION_SCHEMA) missing-schema-adapter
Schema change detected for 'clone' which is used in torch/csrc/stable/
ops.h:
Old schema:
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
New schema:
clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True)
-> Tensor
Please register a schema adapter in torch/csrc/shim_common.cpp
in the _register_adapters() function to handle this schema change.
See #165284 for an example.
```
Registering something in _register_adapters in shim_common.cpp with the correct version makes this lint error go away
[ghstack-poisoned]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first step to remind users to add schema_adapters. A second step will be the testing framework.
This PR adds the linter STABLE_NATIVE_FUNCTION_SCHEMA
Which
torch/csrc/stable/ops.hfor functions called viatorch_call_dispatcherand populates these intorch/csrc/stable/native_ops.txttorch/csrc/stable/native_ops.txt, checks whether any of the functions in questions had their schemas modified in native_functions.yaml anda. Checks if the change was the value of the default for an argument changing --> WARNING for user to update ops.h (this will be properly enforced by the testing framework).
b. Checks whether the change warrants an adapter registration --> ERROR unless the user registers an adapter for the appropriate version in torch/csrc/shim_common.cpp (this will be properly tested by the testing framework)
Examples
cloneto- func: clone(Tensor self, *, MemoryFormat? memory_format=None, bool foo=True) -> TensorRegistering something in _register_adapters in shim_common.cpp with the correct version makes this lint error go away
Stack from ghstack (oldest at bottom):