[xpu][feature] enable Sycl CPP extension on Windows#162579
[xpu][feature] enable Sycl CPP extension on Windows#162579tbohutyn wants to merge 6 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/162579
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: xpu" |
|
@tbohutyn, can you, please, make 2 book keeping changes:
|
torch/utils/cpp_extension.py
Outdated
| ] | ||
| if IS_WINDOWS: | ||
| host_cflags = [ | ||
| "-fsycl", |
There was a problem hiding this comment.
I'm curious why Windows build requires -fsycl, while Linux does not.
|
|
||
|
|
||
| def _prepare_ldflags(extra_ldflags, with_cuda, verbose, is_standalone): | ||
| def _prepare_ldflags(extra_ldflags, with_cuda, with_sycl, verbose, is_standalone): |
There was a problem hiding this comment.
Could you help generalize it a little bit by handling with_cuda and with_sycl with different functions accordingly?
feb3469 to
335362b
Compare
|
|
||
| external_include = _join_sycl_home("include").replace("\\", "\\\\") | ||
| wrapped_host_cflags = [ | ||
| f"-fsycl-host-compiler={host_cxx}", |
There was a problem hiding this comment.
The /std:c++17 which you add on the next line is actually handled by append_std17_if_no_std_present(host_cflags) which you also call. Can you drop explicit /std:c++17 from the line below?
335362b to
2226143
Compare
0e32f7c to
b05ee61
Compare
b05ee61 to
4f0320f
Compare
| extra_ldflags.append(f'-L{_join_rocm_home("lib")}') | ||
| extra_ldflags.append('-lamdhip64') | ||
| if with_sycl: | ||
| if IS_WINDOWS: |
There was a problem hiding this comment.
@dvrogozh I know this is not directly related to this PR, but I’m curious — why isn’t there a Linux branch here?
There was a problem hiding this comment.
I looked into this. These libraries are needed for both Windows and Linux, otherwise there will be unresolved symbols. The reason why it works on Linux without adding these libraries on the command line is 1) lazy linkage on the build stage, 2) global symbol resolution at runtime (i.e. required libraries are already loaded by import torch by the time extension is being loaded and symbols got resolved).
I think it makes sense to align the code between xpu and cuda/hip and add these libs on Linux as well. @tbohutyn, I have submitted a PR against your fork: tbohutyn#1. It adds libs on Linux and adds a test to formally test this out. Please, take a look on PR and merge to your fork if you are ok with it. Once done your pytorch PR will be automatically updated.
There was a problem hiding this comment.
@tbohutyn, can you, please, take a look at tbohutyn#1 PR and let me know if you plan to merge it in or you would like me to follow up on 162579 once it's merged?
There was a problem hiding this comment.
I think it would be better to handle this as a follow-up since it targets Linux, while this PR focuses on Windows.
There was a problem hiding this comment.
I am fine with that. I'll post the Linux PR as soon as this one will get merged as they partially overlap and there will be conflicts to resolve. @guangyey, please, help to merge Windows PR.
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
| shutil.rmtree(temp_dir) | ||
| if IS_WINDOWS: | ||
| # rmtree returns permission error: [WinError 5] Access is denied | ||
| # on Windows, this is a workaround |
There was a problem hiding this comment.
Why not set ignore_error=True in rmtree?
There was a problem hiding this comment.
@tbohutyn : can you, please, check if that's something which can be quick addressed? If not, please, post a note here and let's do that as a follow up.
|
Hi @EikanWang |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: xpu / linux-noble-xpu-n-py3.10 / test (default, 7, 12, linux.idc.xpu) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 0 checks: Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: xpu / linux-noble-xpu-n-py3.10 / test (default, 7, 12, linux.idc.xpu) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
A follow up on the noticed Linux specific issue for sycl cpp extension. We need to link with more libraries we are linking so far. Issue got unnoticed as these libraries were already loaded during torch import. This commit adds missing libs formally to the linker cmdline and adds test for such a case. See pytorch#162579 (comment) Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
A follow up on the noticed Linux specific issue for sycl cpp extension. We need to link with more libraries we are linking so far. Issue got unnoticed as these libraries were already loaded during torch import. This commit adds missing libs formally to the linker cmdline and adds test for such a case. See pytorch#162579 (comment) Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
A follow up on the noticed Linux specific issue for sycl cpp extension. We need to link with more libraries we are linking so far. Issue got unnoticed as these libraries were already loaded during torch import. The dd18a75 commit has added missing libs formally to the linker cmdline. Current commit further adds test for such a case. See pytorch#162579 (comment) Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
A follow up on the noticed Linux specific issue for sycl cpp extension. We need to link with more libraries we are linking so far. Issue got unnoticed as these libraries were already loaded during torch import. The dd18a75 commit has added missing libs formally to the linker cmdline. Current commit further adds test for such a case. See pytorch#162579 (comment) Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
PR for enabling #153265 on Windows Pull Request resolved: #162579 Approved by: https://github.com/dvrogozh, https://github.com/EikanWang, https://github.com/guangyey, https://github.com/albanD
PR for enabling #153265 on Windows