-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add torch.xpu.get_arch_list and torch.xpu.get_gencode_flags for XPU #137773
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/137773
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 7db91db with merge base 28a521e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Pls. add test cases.
|
By the way, Pls. help refine the PR title a little bit. |
# Motivation To support `torch.xpu.get_arch_list` and `torch.xpu.get_gencode_flags`. This PR is related to pytorch/pytorch#137773
Done. |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nits, but sounds good!
| arch_flags = torch._C._xpu_getArchFlags() | ||
| if arch_flags is None: | ||
| return [] | ||
| return arch_flags.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the default for split to split across "," ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your approval. By default any whitespace is a separator. This is expected.
We need to set env variable TORCH_XPU_ARCH_LIST via splitting arch name with commas here . And we have to replace commas with whitespace in TORCH_XPU_ARCH_LIST here. The reason is that C10_STRINGIZE, used in this line, is a macro which could process only an argument into a string (it will consider input separated by commas as multi-arguments, resulting a compilation error). So, _xpu_getArchFlags will return an arch string separated by whitespace instead of commas.
| arch_list = get_arch_list() | ||
| if len(arch_list) == 0: | ||
| return "" | ||
| return f'-device {",".join(arch for arch in arch_list)}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just f'-device {torch._C._xpu_getArchFlags()}' ? :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described above, torch._C._xpu_getArchFlags will return an arch list without commas. And here we expect to return the compilation flag, formatted by "-device ats-m150,lnl-m", that the compiler can recognize.
|
@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 |
Stack from ghstack (oldest at bottom):
Motivation
Add
torch.xpu.get_arch_list()andtorch.xpu.get_gencode_flags()methods that return architecture list and AOT flags to preserve what flags PyTorch XPU was built with.cc @albanD @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10