Skip to content

[Reland] Install xpu codegen header to torch/include #1743

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

Merged
merged 4 commits into from
Jun 27, 2025
Merged

Conversation

guangyey
Copy link
Contributor

@guangyey guangyey commented Jun 15, 2025

Motivation

This PR addresses a code generation issue related to XPU. Currently, there are two separate codegen paths for XPU:

  1. Stock PyTorch – Generates code for oneDNN ops.
  2. torch-xpu-ops – Generates code for SYCL kernel ops.

The corresponding build directories are:

  1. build/aten/src/ATen (for stock PyTorch)
  2. build/xpu/ATen (for torch-xpu-ops)

However, in the torch-xpu-ops codegen, we mistakenly omitted installing XPU op headers from build/xpu/ATen/ops to build/aten/src/ATen/ops. This PR fixes the issue and also removes some unnecessary code for better maintainability.

Solution

We copy the codegen from torch-xpu-ops to stock PyTorch

Additional Context

The original PR is #1405
Fix pytorch/pytorch#145902

@Copilot Copilot AI review requested due to automatic review settings June 15, 2025 07:51
@guangyey guangyey marked this pull request as draft June 15, 2025 07:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the header installation for the torch-xpu-ops codegen by updating include paths for XPU op headers and adjusting CMake scripts.

  • Updated include directives in multiple XPU source files to reference the proper directory (ATen/ops).
  • Modified CMakeLists.txt and Codegen.cmake to copy generated XPU op headers into stock PyTorch’s include directory.

Reviewed Changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated no comments.

File Description
src/ATen/native/xpu/*.cpp Updated include paths from "xpu/ATen/ops" to "ATen/ops".
src/ATen/CMakeLists.txt Added installation of generated XPU header files into ATen/ops.
cmake/Codegen.cmake Introduced variable BUILD_TORCH_ATEN_GENERATED and header install commands to support header installation.

@guangyey guangyey changed the title [Reland] Install xpu codegen header to torch/include [WIP] [WIP] [Reland] Install xpu codegen header to torch/include Jun 15, 2025
@guangyey guangyey changed the title [WIP] [WIP] [Reland] Install xpu codegen header to torch/include [WIP] [Reland] Install xpu codegen header to torch/include Jun 15, 2025
@guangyey guangyey force-pushed the guangyey/codegen branch 6 times, most recently from 655b4fa to b04c7b7 Compare June 20, 2025 18:36
@guangyey guangyey changed the title [WIP] [Reland] Install xpu codegen header to torch/include [Reland] Install xpu codegen header to torch/include Jun 20, 2025
@guangyey guangyey marked this pull request as ready for review June 20, 2025 18:39
@guangyey guangyey added windows_ci Only for Windows CI trigger os: Windows Windows Platform enhancement New feature or request labels Jun 20, 2025
@guangyey guangyey requested a review from chunhuanMeng June 24, 2025 07:56
Copy link
Contributor

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big one, difficult to review. But it's better with this change than without as it blocks certain types of pytorch xpu usage. Better to land and face consequences, if any. I hope it won't be reverted again. If something will go wrong - please, let's discuss before doing harsh reverts!

@guangyey
Copy link
Contributor Author

@chunhuanMeng May I know if the Windows build issue has been resolved.

@chunhuanMeng
Copy link
Contributor

@chunhuanMeng May I know if the Windows build issue has been resolved.

Yes, I have tested it on Windows.

@guangyey
Copy link
Contributor Author

Let’s try landing it and see what happens.

@guangyey guangyey added this pull request to the merge queue Jun 27, 2025
Merged via the queue into main with commit 51d33c6 Jun 27, 2025
8 of 9 checks passed
@guangyey guangyey deleted the guangyey/codegen branch June 27, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request os: Windows Windows Platform windows_ci Only for Windows CI trigger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xpu: installed pytorch is missing aten xpu ops headers (ATen/ops/cat_xpu_dispatch.h and others)
4 participants