Skip to content
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

Add UTs for accelerator device-agnostic runtime APIs #133572

Open
wants to merge 44 commits into
base: gh/guangyey/62/base
Choose a base branch
from

Conversation

Copy link

pytorch-bot bot commented Aug 15, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/133572

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 3edb0d1 with merge base 8b08559 (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.

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Aug 15, 2024
guangyey added a commit that referenced this pull request Aug 15, 2024
ghstack-source-id: 3b5de65108564ad6ba0cf32c8e60ffee13e052f8
Pull Request resolved: #133572
@guangyey guangyey marked this pull request as draft August 15, 2024 14:54
@guangyey guangyey changed the title Add UTs for accelerator device-agnostic runtime APIs [WIP] Add UTs for accelerator device-agnostic runtime APIs Aug 15, 2024
[ghstack-poisoned]
guangyey added a commit that referenced this pull request Aug 16, 2024
ghstack-source-id: 337ac201e83fda8799bbb69b5d77bd6bfb5fb9ed
Pull Request resolved: #133572
@guangyey guangyey added the intel This tag is for PR from Intel label Aug 16, 2024
guangyey added a commit that referenced this pull request Aug 16, 2024
ghstack-source-id: 6438fec6be2f0d751fbd37fd51bddcfeb6914fea
Pull Request resolved: #133572
@guangyey guangyey changed the title [WIP] Add UTs for accelerator device-agnostic runtime APIs Add UTs for accelerator device-agnostic runtime APIs Aug 16, 2024
@guangyey guangyey marked this pull request as ready for review August 16, 2024 08:39
@guangyey guangyey requested a review from albanD August 16, 2024 08:39
[ghstack-poisoned]
[ghstack-poisoned]
self.assertEqual(torch.current_accelerator(), "xpu")

@unittest.skipIf(not TEST_ACCELERATOR, "no avaliable accelerators detected")
def test_generic_multi_device_behavior(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add device to the input parameter. So that you can check if the current device type is the same as the input device type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refine the UTs to be more general.

test/test_accelerator.py Outdated Show resolved Hide resolved
test/test_accelerator.py Show resolved Hide resolved
guangyey added a commit that referenced this pull request Oct 4, 2024
ghstack-source-id: a1b18c010dedad2fa34d699c0b84a175a0de1df2
Pull Request resolved: #133572
guangyey added a commit that referenced this pull request Oct 4, 2024
ghstack-source-id: e41814af0228407ea8baba358a5042077900be3a
Pull Request resolved: #133572
[ghstack-poisoned]
[ghstack-poisoned]
guangyey added a commit that referenced this pull request Oct 8, 2024
ghstack-source-id: 2b5145530fdfa5d44ae9a389df17c37a3f9c4cbb
Pull Request resolved: #133572
guangyey added a commit that referenced this pull request Oct 8, 2024
ghstack-source-id: 70812fef1aef8ca55489f7232debeb5e0044bbe6
Pull Request resolved: #133572
guangyey added a commit that referenced this pull request Oct 8, 2024
ghstack-source-id: 2f42f774db9b05b6d60fcb47ef5aa531e24a08f0
Pull Request resolved: #133572
@guangyey guangyey marked this pull request as draft October 8, 2024 01:47
@guangyey guangyey changed the title Add UTs for accelerator device-agnostic runtime APIs [WIP] Add UTs for accelerator device-agnostic runtime APIs Oct 8, 2024
guangyey added a commit that referenced this pull request Oct 8, 2024
ghstack-source-id: a4c9660c2fc09af9e94047994d33b52ee0277730
Pull Request resolved: #133572
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey
Copy link
Collaborator Author

Unrelated failures, please refer to #138548

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey guangyey added ciflow/rocm ciflow/mps Run MPS tests (subset of trunk) labels Oct 26, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey guangyey requested a review from malfet October 28, 2024 03:08
@guangyey
Copy link
Collaborator Author

Hi @malfet , May I know if you could help review this separate PR? This PR aims to add some UTs to test these APIs introduced by the previous PR.

class TestAccelerator(TestCase):
def test_current_accelerator(self):
self.assertTrue(torch.accelerator.is_available())
accelerators = ["cuda", "xpu"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why hip and mps are not part of the list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hip will be covered as it is masqued as cuda. And added mps to the list.


@unittest.skipIf((not TEST_CUDA) and (not TEST_XPU), "requires CUDA or XPU")
def test_specific_stream_compatibility(self):
s1 = torch.cuda.Stream() if torch.cuda.is_available() else torch.xpu.Stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, why hip and mps are not considered?

Copy link
Collaborator Author

@guangyey guangyey Oct 28, 2024

Choose a reason for hiding this comment

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

hip will be covered as it is masqued as cuda. Here mps is not considered as mps doesn't have the device-specific stream torch.mps.Stream.

[ghstack-poisoned]
@guangyey guangyey requested a review from malfet October 29, 2024 02:52
[ghstack-poisoned]
@guangyey
Copy link
Collaborator Author

@malfet May I know if I have addressed your comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/mps Run MPS tests (subset of trunk) ciflow/rocm ciflow/xpu Run XPU CI tasks intel This tag is for PR from Intel open source topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants