Skip to content

Conversation

@mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Nov 4, 2025

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 https://github.com/pytorch/pytorch/pull/165284/ for an example.
  

Registering something in _register_adapters in shim_common.cpp with the correct version makes this lint error go away

Stack from ghstack (oldest at bottom):

@pytorch-bot
Copy link

pytorch-bot bot commented 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 Failures

As of commit 9cda7d6 with merge base 77b9399 (image):
💚 Looks good so far! There are no failures yet. 💚

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]
mikaylagawarecki added a commit that referenced this pull request Nov 4, 2025
…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]
mikaylagawarecki added a commit that referenced this pull request Nov 7, 2025
…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]
mikaylagawarecki added a commit that referenced this pull request Nov 7, 2025
…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]
mikaylagawarecki added a commit that referenced this pull request Nov 7, 2025
…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]
mikaylagawarecki added a commit that referenced this pull request Nov 7, 2025
@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review November 12, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants