-
Notifications
You must be signed in to change notification settings - Fork 989
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
Use torch.xpu.mem_get_info for XPU #3275
base: main
Are you sure you want to change the base?
Conversation
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 ! Just a few nits
src/accelerate/utils/memory.py
Outdated
# It further requires PyTorch built with the SYCL runtime which supports API | ||
# to query available device memory. If not available, exception will be | ||
# raised. |
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 there a link to show to the user how to build it with SYCL runtime ?
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.
I've updated comment a little to clarify the story around SYCL version. It's tight to the version of DPC++ SYCL compiler used to build pytorch with XPU backend support. It's reported with print(torch.version.xpu)
and the first version to support required feature is 20250001
. I think link on how to build is not necessary here in accelerate comments since that's a generic link to pytorch documentation on how to build it with XPU backend support. I.e. https://github.com/pytorch/pytorch?tab=readme-ov-file#intel-gpu-support. It further links to intel side documentation to install required environment which includes DPC++ SYCL compiler (this one: https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpus.html).
Note that I deliberately used try...catch
here instead of version checks around torch.version.xpu
since I think that's better approach. SYCL support is getting upstream to clang and in the future there might be at least 2 compilers supporting it - intel dpc++ one and clang. I think using try...catch
would handle such situation in accelerate counting for the future. We can discuss this further if needed.
torch.xpu.mem_get_info API is available starting from PyTorch 2.6 (and in nightly 2.6.0.dev20241206+xpu or later). To work properly this method requires PyTorch built with the SYCL runtime which supports API to query device memory stats. If not available, exception will be raised. Requires: pytorch/pytorch#141230 Fixes: huggingface#2929 Fixes: huggingface/transformers#31922 Signed-off-by: Dmitry Rogozhkin <[email protected]>
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 doing this!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Failing ci test:
Is this a know test flakiness? I guess there is no currently Intel GPUs in the ci. If so this PR should not have an effect on the test run. |
Rerun for prev. failing test have passed. New ci failure also seems unrelated:
|
torch.xpu.mem_get_info
API is available starting from PyTorch 2.6 (and in nightly2.6.0.dev20241206+xpu
or later). To work properly this method requires PyTorch built with the SYCL runtime which supports API to query device memory stats. If not available, exception will be raised.Requires: pytorch/pytorch#141230
Fixes: #2929
Fixes: huggingface/transformers#31922
CC: @muellerzr @SunMarc