Skip to content

Conversation

@guangyey
Copy link
Collaborator

@guangyey guangyey commented Nov 21, 2024

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

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 21, 2024

🔗 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 (image):

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.

@guangyey guangyey marked this pull request as draft November 21, 2024 11:16
@guangyey guangyey changed the title Support torch.xpu.mem_get_info API [WIP] Support torch.xpu.mem_get_info API Nov 21, 2024
@guangyey guangyey added this to the 2.6.0 milestone Nov 21, 2024
@guangyey guangyey added ciflow/xpu Run XPU CI tasks release notes: xpu release notes category module: xpu Intel XPU related issues ciflow/trunk Trigger trunk jobs on your pull request labels Nov 21, 2024
guangyey added a commit that referenced this pull request Nov 21, 2024
ghstack-source-id: 1446618
Pull Request resolved: #141230
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
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.

We have open issue for this API. Please, add to description that it fixes #130599

guangyey added a commit that referenced this pull request Nov 22, 2024
ghstack-source-id: e0f3461
Pull Request resolved: #141230
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey
Copy link
Collaborator Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

[ghstack-poisoned]
[ghstack-poisoned]
@guangyey
Copy link
Collaborator Author

guangyey commented Dec 4, 2024

We have filed an issue to track this unrelated failure, refer to #141861

@EikanWang
Copy link
Collaborator

@albanD , @ezyang , @malfet , @atalman , may I know if you have comments regarding this PR?

if :attr:`device` is ``None`` (default).
Returns:
int: the memory avialble on the device in units of bytes.
Copy link
Contributor

Choose a reason for hiding this comment

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

available

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ezyang Updated. Thanks.

guangyey added a commit that referenced this pull request Dec 4, 2024
ghstack-source-id: 122d13b
Pull Request resolved: #141230
@guangyey guangyey requested a review from ezyang December 4, 2024 04:12
[ghstack-poisoned]
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM !

Py_RETURN_NONE;
}

PyObject* THXPModule_getMemoryInfo(PyObject* self, PyObject* arg) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

guangyey added a commit that referenced this pull request Dec 5, 2024
ghstack-source-id: e661a5d
Pull Request resolved: #141230
@guangyey
Copy link
Collaborator Author

guangyey commented Dec 5, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

[ghstack-poisoned]
[ghstack-poisoned]
dvrogozh added a commit to dvrogozh/accelerate that referenced this pull request Dec 6, 2024
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]>
dvrogozh added a commit to dvrogozh/accelerate that referenced this pull request Dec 6, 2024
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]>
AmdSampsa pushed a commit to AmdSampsa/pytorch that referenced this pull request Dec 9, 2024
dvrogozh added a commit to dvrogozh/accelerate that referenced this pull request Dec 9, 2024
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]>
SunMarc pushed a commit to huggingface/accelerate that referenced this pull request Dec 24, 2024
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]>
@github-actions github-actions bot deleted the gh/guangyey/101/head branch January 5, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged module: xpu Intel XPU related issues open source release notes: xpu release notes category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants