-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Support torch.xpu.mem_get_info API #141230
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/141230
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit e7cc11e with merge base d633cf1 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
dvrogozh
left a comment
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.
We have open issue for this API. Please, add to description that it fixes #130599
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
We have filed an issue to track this unrelated failure, refer to #141861 |
torch/xpu/memory.py
Outdated
| if :attr:`device` is ``None`` (default). | ||
| Returns: | ||
| int: the memory avialble on the device in units of bytes. |
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.
available
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.
@ezyang Updated. Thanks.
albanD
left a comment
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.
SGTM !
torch/csrc/xpu/Module.cpp
Outdated
| Py_RETURN_NONE; | ||
| } | ||
|
|
||
| PyObject* THXPModule_getMemoryInfo(PyObject* self, PyObject* arg) { |
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.
nit: use pybind11 for this kind of functions. It makes the code simpler to maintain.
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, @albanD, pybind11 makes my life easier. We will file another PR to bind these methods left in this file via pybind11.
|
@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 |
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]>
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]>
# Motivate Fix pytorch#130599 This PR intends to add a new API, `torch.xpu.mem_get_info,` which is widely used in popular model workloads. For example, [here](https://github.com/huggingface/accelerate/blob/403c0714d1dd019a481022afce5df75a9963ecd9/src/accelerate/utils/modeling.py#L721) we need to get current GPU memory usage to split or load the model. Pull Request resolved: pytorch#141230 Approved by: https://github.com/EikanWang, https://github.com/albanD
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]>
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: #2929 Fixes: huggingface/transformers#31922 Signed-off-by: Dmitry Rogozhkin <[email protected]>
Stack from ghstack (oldest at bottom):
Motivate
Fix #130599
This PR intends to add a new API,
torch.xpu.mem_get_info,which is widely used in popular model workloads.For example, here we need to get current GPU memory usage to split or load the model.
cc @gujinghui @EikanWang @fengyuan14