Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180190
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 6 Unrelated FailuresAs of commit 398f987 with merge base 5c3f8fd ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Attention! PyTorch one of the C-stable API file was changedYou MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function. Caused by: |
|
@janeyx99 has imported this pull request. If you are a Meta employee, you can view this in D100546620. |
a5af64e to
98424df
Compare
|
@janeyx99 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100546620. |
| aoti_torch_dtype_float4_e2m1fn_x2: TORCH_VERSION_2_12_0 | ||
| aoti_torch_dtype_float8_e8m0fnu: TORCH_VERSION_2_12_0 |
There was a problem hiding this comment.
These are from a previous commit #176496 that our linter wasn't triggered on
| @@ -2101,6 +2101,7 @@ def gen_headers( | |||
| static_dispatch_idx: list[BackendIndex], | |||
| selector: SelectiveBuilder, | |||
| backend_indices: dict[DispatchKey, BackendIndex], | |||
| headeronly_fm: FileManager, | |||
There was a problem hiding this comment.
These changes look reasonable to me but I am not sure who the best reviewer would be. Also my inclination is that we don't care about the BC lint here?
albanD
left a comment
There was a problem hiding this comment.
Small nit on test, but sounds good otherwise!
|
|
||
| STABLE_TORCH_LIBRARY_FRAGMENT(STABLE_LIB_NAME, m) { | ||
| m.def("tagged_identity(Tensor t) -> Tensor", | ||
| {torch::headeronly::Tag::pointwise}); |
There was a problem hiding this comment.
Can you do a test with multiple tags?
Pulled By: janeyx99 janeyx99 Differential Revision: D100546620
2c76b8a to
099483e
Compare
…180190) Pulled By: janeyx99 janeyx99 janeyx99 Differential Revision: D100546620
5c0c135 to
c747bed
Compare
…180190) Pulled By: janeyx99 janeyx99 janeyx99 Differential Revision: D100546620
c747bed to
ca17dad
Compare
Needed to land my tags PR #180190 which failed XPU build again due to a land race with Richard's PR adding a new tag. Pull Request resolved: #181408 Approved by: https://github.com/malfet, https://github.com/atalman
The best scenario is to not have a different copy here, but this fix will unblock my PR's broken XPU build. pytorch/pytorch#180190 Co-authored-by: chuanqi129 <[email protected]>
|
Landed in #181161 |
* [pytorch][PR] Reland D100546620: Move at::Tag to headeronly, add library.def override to allow tags (#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: #180190 Differential Revision: D102031366 Pull Request resolved: #181161 Approved by: https://github.com/seemethere, https://github.com/atalman * Change default of torchgen headeronly-install-dir to depend on install-dir (#181434) This is a "forward fix" of #181161 and will need to be cherrypicked to make sure xpu builds still work. To describe the issue: - torch-xpu-ops has its own version of tags.yaml - the natural default of headeronly-install-dir had the XPU build overriding the enum_tags.h, and since their tag.yaml weren't the same as ours, we get build issues - I tried fixing this before by just aligning the torch-xpu-ops version of tags.yaml but we're still adding more tags so that problem will come back - I finally decided the fix is just to make the the default doesn't have the install locations colliding even if it makes the default for torchgen a tad more complicated. Test plan: make sure the XPU build on the PR stacked on top of this one passes. Pull Request resolved: #181434 Approved by: https://github.com/EikanWang, https://github.com/wdvr
The best scenario is to not have a different copy here, but this fix will unblock my PR's broken XPU build. pytorch/pytorch#180190
…ml (#181233) # Motivation Currently, PyTorch XPU ATen ops are split across two locations: - operations that call oneDNN (e.g., GEMM, convolution) reside in [ATen/native/mkldnn/xpu](https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native/mkldnn/xpu); - while those implemented with SYCL are located [in torch-xpu-ops](https://github.com/intel/torch-xpu-ops/tree/main/src/ATen/native/xpu). The operations in PyTorch are declared and registered in [pytorch/aten/src/ATen/native/native_functions.yaml](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml#L651), whereas the SYCL-based operations in torch-xpu-ops are declared and registered in [yaml/native/native_functions.yaml](https://github.com/intel/torch-xpu-ops/blob/main/yaml/native/native_functions.yaml#L87). This setup introduces a complication: When building PyTorch with XPU support, `torch-gen` needs to be run twice: - once during the build of torch-xpu at [here](https://github.com/pytorch/pytorch/blob/5aac4cfce409ae24f7f0fe3e95f9a3cf5bdf4a28/cmake/Codegen.cmake#L232-L241) and - again during the build of torch-xpu-ops at [here](https://github.com/intel/torch-xpu-ops/blob/8d373ba272f9fed348c7684bac4a0c2663844bbd/cmake/Codegen.cmake#L99-L125). This solution introduces two issues (for more details, see [Details](#details)): 1. We need to maintain an additional `native_functions.yaml` in torch-xpu-ops, which may lead to unexpected behavior if it becomes out of sync with the one in PyTorch. For example, changes to `codegen` (e.g., #180190) may break XPU CI because XPU ATen kernel registrations are out-of-tree. This creates additional maintenance overhead for both PyTorch and torch-xpu-ops. 2. It creates a build dependency; torch-xpu-ops must wait for the torch-cpu build to finish, which increases overall build time and complexity. It also retriggers the re-compile XPU (depends on libtorch_cpu.so) due to any CPU code change. To resolve the issues mentioned above, we would like to migrate XPU ATen kernel registration to `native_functions.yaml` in PyTorch and reuse its codegen fully. # Solution If we could move the ops declarations from torch-xpu-ops into torch’s native_functions.yaml, both problems would be resolved. The key benefits: 1. Single code generation pass – run torch-gen only once instead of twice, simple and more efficient build process 2. Eliminate build dependency – enable parallel builds of torch-cpu and torch-xpu-ops 3. Single source of truth – maintain only one `native_functions.yaml` file, prevent XPU CI break by torchgen and YAML changes. # Additional Context ## Details <img width="1661" height="966" alt="image" src="https://github.com/user-attachments/assets/06574feb-1038-4d9a-bfdd-f4bb0444ecd2" /> We have to maintain a very complicated build flow: - first `torchgen` in PyTorch, the left one of the picture, it will generate XPUFunctions_inl.h, oneDNN-based dispatch headers (e.g., `addmm_xpu_dispatch.h`), and some partial native declarations (e.g., `dot_native.h`). At this stage, SYCL-based ops (e.g., `dot`) are not included, and corresponding dispatch headers and declarations are not generated. - second `torchgen` in torch-xpu-ops, the right one of the picture, generates SYCL-based dispatch headers (e.g., `dot_xpu_dispatch.h`) and corresponding native declarations (e.g., `dot_native.h`). - After 2nd `torchgen`, we copy the newly generated files and declarations back into `<Aten/ops>` folders, and update the corresponding native headers, for example, `dot_xpu_dispatch.h` is copied into `<Aten/ops>` folder and update `dot_native.h` and `XPUFunctions_inl.h` accordingly. We do this for two reasons: 1. fully reusing torchgen; 2. exposing Aten xpu ops header to public. So developers can include headers like `<Aten/ops/dot_xpu_dispatch.h>` when building C++ extensions (similar to CPU and CUDA). However, building `libtorch_cpu.so` depends on `dot_native.h`, which is also updated during the second `torchgen`. As a result, we must wait for `libtorch_cpu.so` to finish building before running the second `torchgen`, otherwise, a read-write race may happen if `dot_native.h` is modified while still being used. This can lead to a build failure, especially on Windows. It also introduces an implicit dependency, causing unnecessary recompilation of XPU whenever CPU code changes. ## Deprecated - _empty_affine_quantized - _empty_per_channel_affine_quantized - quantized_max_pool2d_xpu - _safe_softmax_xpu Pull Request resolved: #181233 Approved by: https://github.com/EikanWang, https://github.com/albanD
…ml (pytorch#181233) Currently, PyTorch XPU ATen ops are split across two locations: - operations that call oneDNN (e.g., GEMM, convolution) reside in [ATen/native/mkldnn/xpu](https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native/mkldnn/xpu); - while those implemented with SYCL are located [in torch-xpu-ops](https://github.com/intel/torch-xpu-ops/tree/main/src/ATen/native/xpu). The operations in PyTorch are declared and registered in [pytorch/aten/src/ATen/native/native_functions.yaml](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml#L651), whereas the SYCL-based operations in torch-xpu-ops are declared and registered in [yaml/native/native_functions.yaml](https://github.com/intel/torch-xpu-ops/blob/main/yaml/native/native_functions.yaml#L87). This setup introduces a complication: When building PyTorch with XPU support, `torch-gen` needs to be run twice: - once during the build of torch-xpu at [here](https://github.com/pytorch/pytorch/blob/5aac4cfce409ae24f7f0fe3e95f9a3cf5bdf4a28/cmake/Codegen.cmake#L232-L241) and - again during the build of torch-xpu-ops at [here](https://github.com/intel/torch-xpu-ops/blob/8d373ba272f9fed348c7684bac4a0c2663844bbd/cmake/Codegen.cmake#L99-L125). This solution introduces two issues (for more details, see [Details](#details)): 1. We need to maintain an additional `native_functions.yaml` in torch-xpu-ops, which may lead to unexpected behavior if it becomes out of sync with the one in PyTorch. For example, changes to `codegen` (e.g., pytorch#180190) may break XPU CI because XPU ATen kernel registrations are out-of-tree. This creates additional maintenance overhead for both PyTorch and torch-xpu-ops. 2. It creates a build dependency; torch-xpu-ops must wait for the torch-cpu build to finish, which increases overall build time and complexity. It also retriggers the re-compile XPU (depends on libtorch_cpu.so) due to any CPU code change. To resolve the issues mentioned above, we would like to migrate XPU ATen kernel registration to `native_functions.yaml` in PyTorch and reuse its codegen fully. If we could move the ops declarations from torch-xpu-ops into torch’s native_functions.yaml, both problems would be resolved. The key benefits: 1. Single code generation pass – run torch-gen only once instead of twice, simple and more efficient build process 2. Eliminate build dependency – enable parallel builds of torch-cpu and torch-xpu-ops 3. Single source of truth – maintain only one `native_functions.yaml` file, prevent XPU CI break by torchgen and YAML changes. <img width="1661" height="966" alt="image" src="https://github.com/user-attachments/assets/06574feb-1038-4d9a-bfdd-f4bb0444ecd2" /> We have to maintain a very complicated build flow: - first `torchgen` in PyTorch, the left one of the picture, it will generate XPUFunctions_inl.h, oneDNN-based dispatch headers (e.g., `addmm_xpu_dispatch.h`), and some partial native declarations (e.g., `dot_native.h`). At this stage, SYCL-based ops (e.g., `dot`) are not included, and corresponding dispatch headers and declarations are not generated. - second `torchgen` in torch-xpu-ops, the right one of the picture, generates SYCL-based dispatch headers (e.g., `dot_xpu_dispatch.h`) and corresponding native declarations (e.g., `dot_native.h`). - After 2nd `torchgen`, we copy the newly generated files and declarations back into `<Aten/ops>` folders, and update the corresponding native headers, for example, `dot_xpu_dispatch.h` is copied into `<Aten/ops>` folder and update `dot_native.h` and `XPUFunctions_inl.h` accordingly. We do this for two reasons: 1. fully reusing torchgen; 2. exposing Aten xpu ops header to public. So developers can include headers like `<Aten/ops/dot_xpu_dispatch.h>` when building C++ extensions (similar to CPU and CUDA). However, building `libtorch_cpu.so` depends on `dot_native.h`, which is also updated during the second `torchgen`. As a result, we must wait for `libtorch_cpu.so` to finish building before running the second `torchgen`, otherwise, a read-write race may happen if `dot_native.h` is modified while still being used. This can lead to a build failure, especially on Windows. It also introduces an implicit dependency, causing unnecessary recompilation of XPU whenever CPU code changes. - _empty_affine_quantized - _empty_per_channel_affine_quantized - quantized_max_pool2d_xpu - _safe_softmax_xpu Pull Request resolved: pytorch#181233 Approved by: https://github.com/EikanWang, https://github.com/albanD (cherry picked from commit 7b04342)
…ytorch#180190) (pytorch#180190) Summary: Custom ops benefit from using tags. Let's make them usable--they're already headeronly (it's an enum) but the major pain of this change is needing to codev it and fight internal. Claude was v helpful tho! This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Differential Revision: D100546620 Pulled By: janeyx99 Pull Request resolved: pytorch#180190 Approved by: https://github.com/albanD
…w tags (pytorch#180190) (pytorch#180190)" This reverts commit 85c505b. Reverted pytorch#180190 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#180190 (comment)))
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere, https://github.com/atalman
Needed to land my tags PR pytorch#180190 which failed XPU build again due to a land race with Richard's PR adding a new tag. Pull Request resolved: pytorch#181408 Approved by: https://github.com/malfet, https://github.com/atalman
…ytorch#180190) (pytorch#180190) Summary: Custom ops benefit from using tags. Let's make them usable--they're already headeronly (it's an enum) but the major pain of this change is needing to codev it and fight internal. Claude was v helpful tho! This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Differential Revision: D100546620 Pulled By: janeyx99 Pull Request resolved: pytorch#180190 Approved by: https://github.com/albanD
…w tags (pytorch#180190) (pytorch#180190)" This reverts commit 85c505b. Reverted pytorch#180190 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#180190 (comment)))
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere, https://github.com/atalman
Needed to land my tags PR pytorch#180190 which failed XPU build again due to a land race with Richard's PR adding a new tag. Pull Request resolved: pytorch#181408 Approved by: https://github.com/malfet, https://github.com/atalman
…ml (pytorch#181233) # Motivation Currently, PyTorch XPU ATen ops are split across two locations: - operations that call oneDNN (e.g., GEMM, convolution) reside in [ATen/native/mkldnn/xpu](https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native/mkldnn/xpu); - while those implemented with SYCL are located [in torch-xpu-ops](https://github.com/intel/torch-xpu-ops/tree/main/src/ATen/native/xpu). The operations in PyTorch are declared and registered in [pytorch/aten/src/ATen/native/native_functions.yaml](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml#L651), whereas the SYCL-based operations in torch-xpu-ops are declared and registered in [yaml/native/native_functions.yaml](https://github.com/intel/torch-xpu-ops/blob/main/yaml/native/native_functions.yaml#L87). This setup introduces a complication: When building PyTorch with XPU support, `torch-gen` needs to be run twice: - once during the build of torch-xpu at [here](https://github.com/pytorch/pytorch/blob/5aac4cfce409ae24f7f0fe3e95f9a3cf5bdf4a28/cmake/Codegen.cmake#L232-L241) and - again during the build of torch-xpu-ops at [here](https://github.com/intel/torch-xpu-ops/blob/8d373ba272f9fed348c7684bac4a0c2663844bbd/cmake/Codegen.cmake#L99-L125). This solution introduces two issues (for more details, see [Details](#details)): 1. We need to maintain an additional `native_functions.yaml` in torch-xpu-ops, which may lead to unexpected behavior if it becomes out of sync with the one in PyTorch. For example, changes to `codegen` (e.g., pytorch#180190) may break XPU CI because XPU ATen kernel registrations are out-of-tree. This creates additional maintenance overhead for both PyTorch and torch-xpu-ops. 2. It creates a build dependency; torch-xpu-ops must wait for the torch-cpu build to finish, which increases overall build time and complexity. It also retriggers the re-compile XPU (depends on libtorch_cpu.so) due to any CPU code change. To resolve the issues mentioned above, we would like to migrate XPU ATen kernel registration to `native_functions.yaml` in PyTorch and reuse its codegen fully. # Solution If we could move the ops declarations from torch-xpu-ops into torch’s native_functions.yaml, both problems would be resolved. The key benefits: 1. Single code generation pass – run torch-gen only once instead of twice, simple and more efficient build process 2. Eliminate build dependency – enable parallel builds of torch-cpu and torch-xpu-ops 3. Single source of truth – maintain only one `native_functions.yaml` file, prevent XPU CI break by torchgen and YAML changes. # Additional Context ## Details <img width="1661" height="966" alt="image" src="https://github.com/user-attachments/assets/06574feb-1038-4d9a-bfdd-f4bb0444ecd2" /> We have to maintain a very complicated build flow: - first `torchgen` in PyTorch, the left one of the picture, it will generate XPUFunctions_inl.h, oneDNN-based dispatch headers (e.g., `addmm_xpu_dispatch.h`), and some partial native declarations (e.g., `dot_native.h`). At this stage, SYCL-based ops (e.g., `dot`) are not included, and corresponding dispatch headers and declarations are not generated. - second `torchgen` in torch-xpu-ops, the right one of the picture, generates SYCL-based dispatch headers (e.g., `dot_xpu_dispatch.h`) and corresponding native declarations (e.g., `dot_native.h`). - After 2nd `torchgen`, we copy the newly generated files and declarations back into `<Aten/ops>` folders, and update the corresponding native headers, for example, `dot_xpu_dispatch.h` is copied into `<Aten/ops>` folder and update `dot_native.h` and `XPUFunctions_inl.h` accordingly. We do this for two reasons: 1. fully reusing torchgen; 2. exposing Aten xpu ops header to public. So developers can include headers like `<Aten/ops/dot_xpu_dispatch.h>` when building C++ extensions (similar to CPU and CUDA). However, building `libtorch_cpu.so` depends on `dot_native.h`, which is also updated during the second `torchgen`. As a result, we must wait for `libtorch_cpu.so` to finish building before running the second `torchgen`, otherwise, a read-write race may happen if `dot_native.h` is modified while still being used. This can lead to a build failure, especially on Windows. It also introduces an implicit dependency, causing unnecessary recompilation of XPU whenever CPU code changes. ## Deprecated - _empty_affine_quantized - _empty_per_channel_affine_quantized - quantized_max_pool2d_xpu - _safe_softmax_xpu Pull Request resolved: pytorch#181233 Approved by: https://github.com/EikanWang, https://github.com/albanD
…ytorch#180190) (pytorch#180190) Summary: Custom ops benefit from using tags. Let's make them usable--they're already headeronly (it's an enum) but the major pain of this change is needing to codev it and fight internal. Claude was v helpful tho! This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Differential Revision: D100546620 Pulled By: janeyx99 Pull Request resolved: pytorch#180190 Approved by: https://github.com/albanD
…w tags (pytorch#180190) (pytorch#180190)" This reverts commit 85c505b. Reverted pytorch#180190 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#180190 (comment)))
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere
…ary.def override to allow tags (pytorch#181161) Summary: Reland of D100546620 which was reverted by D101431332 due to breaking libhammer.so. Custom ops benefit from using tags. This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags. Note: The two BUILD.bazel changes from the original diff were already present on master (the revert did not touch them), so this reland omits those files. Old PR was: pytorch#180190 Differential Revision: D102031366 Pull Request resolved: pytorch#181161 Approved by: https://github.com/seemethere, https://github.com/atalman
Needed to land my tags PR pytorch#180190 which failed XPU build again due to a land race with Richard's PR adding a new tag. Pull Request resolved: pytorch#181408 Approved by: https://github.com/malfet, https://github.com/atalman
…ml (pytorch#181233) # Motivation Currently, PyTorch XPU ATen ops are split across two locations: - operations that call oneDNN (e.g., GEMM, convolution) reside in [ATen/native/mkldnn/xpu](https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native/mkldnn/xpu); - while those implemented with SYCL are located [in torch-xpu-ops](https://github.com/intel/torch-xpu-ops/tree/main/src/ATen/native/xpu). The operations in PyTorch are declared and registered in [pytorch/aten/src/ATen/native/native_functions.yaml](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml#L651), whereas the SYCL-based operations in torch-xpu-ops are declared and registered in [yaml/native/native_functions.yaml](https://github.com/intel/torch-xpu-ops/blob/main/yaml/native/native_functions.yaml#L87). This setup introduces a complication: When building PyTorch with XPU support, `torch-gen` needs to be run twice: - once during the build of torch-xpu at [here](https://github.com/pytorch/pytorch/blob/5aac4cfce409ae24f7f0fe3e95f9a3cf5bdf4a28/cmake/Codegen.cmake#L232-L241) and - again during the build of torch-xpu-ops at [here](https://github.com/intel/torch-xpu-ops/blob/8d373ba272f9fed348c7684bac4a0c2663844bbd/cmake/Codegen.cmake#L99-L125). This solution introduces two issues (for more details, see [Details](#details)): 1. We need to maintain an additional `native_functions.yaml` in torch-xpu-ops, which may lead to unexpected behavior if it becomes out of sync with the one in PyTorch. For example, changes to `codegen` (e.g., pytorch#180190) may break XPU CI because XPU ATen kernel registrations are out-of-tree. This creates additional maintenance overhead for both PyTorch and torch-xpu-ops. 2. It creates a build dependency; torch-xpu-ops must wait for the torch-cpu build to finish, which increases overall build time and complexity. It also retriggers the re-compile XPU (depends on libtorch_cpu.so) due to any CPU code change. To resolve the issues mentioned above, we would like to migrate XPU ATen kernel registration to `native_functions.yaml` in PyTorch and reuse its codegen fully. # Solution If we could move the ops declarations from torch-xpu-ops into torch’s native_functions.yaml, both problems would be resolved. The key benefits: 1. Single code generation pass – run torch-gen only once instead of twice, simple and more efficient build process 2. Eliminate build dependency – enable parallel builds of torch-cpu and torch-xpu-ops 3. Single source of truth – maintain only one `native_functions.yaml` file, prevent XPU CI break by torchgen and YAML changes. # Additional Context ## Details <img width="1661" height="966" alt="image" src="https://github.com/user-attachments/assets/06574feb-1038-4d9a-bfdd-f4bb0444ecd2" /> We have to maintain a very complicated build flow: - first `torchgen` in PyTorch, the left one of the picture, it will generate XPUFunctions_inl.h, oneDNN-based dispatch headers (e.g., `addmm_xpu_dispatch.h`), and some partial native declarations (e.g., `dot_native.h`). At this stage, SYCL-based ops (e.g., `dot`) are not included, and corresponding dispatch headers and declarations are not generated. - second `torchgen` in torch-xpu-ops, the right one of the picture, generates SYCL-based dispatch headers (e.g., `dot_xpu_dispatch.h`) and corresponding native declarations (e.g., `dot_native.h`). - After 2nd `torchgen`, we copy the newly generated files and declarations back into `<Aten/ops>` folders, and update the corresponding native headers, for example, `dot_xpu_dispatch.h` is copied into `<Aten/ops>` folder and update `dot_native.h` and `XPUFunctions_inl.h` accordingly. We do this for two reasons: 1. fully reusing torchgen; 2. exposing Aten xpu ops header to public. So developers can include headers like `<Aten/ops/dot_xpu_dispatch.h>` when building C++ extensions (similar to CPU and CUDA). However, building `libtorch_cpu.so` depends on `dot_native.h`, which is also updated during the second `torchgen`. As a result, we must wait for `libtorch_cpu.so` to finish building before running the second `torchgen`, otherwise, a read-write race may happen if `dot_native.h` is modified while still being used. This can lead to a build failure, especially on Windows. It also introduces an implicit dependency, causing unnecessary recompilation of XPU whenever CPU code changes. ## Deprecated - _empty_affine_quantized - _empty_per_channel_affine_quantized - quantized_max_pool2d_xpu - _safe_softmax_xpu Pull Request resolved: pytorch#181233 Approved by: https://github.com/EikanWang, https://github.com/albanD
The best scenario is to not have a different copy here, but this fix will unblock my PR's broken XPU build. pytorch/pytorch#180190
Summary:
Custom ops benefit from using tags. Let's make them usable--they're already headeronly (it's an enum) but the major pain of this change is needing to codev it and fight internal. Claude was v helpful tho!
This PR moves at::Tag to torch::headeronly::Tag and adds a shim for stable Library.def to be able to take in tags.
Differential Revision: D100546620
Pulled By: janeyx99