Skip to content

Conversation

@amathewc
Copy link
Contributor

@amathewc amathewc commented Feb 21, 2025

This PR is related to #145476 . That PR had two files (test_functions.py and test_misc.py) . test_functions was causing CI/rebase/merge issues and hence removed for now. This PR contains only test_misc.py.

This is a continuation of #144387 .

MOTIVATION

We recently integrated support for Intel Gaudi devices (identified as 'hpu') into the common_device_type framework via the pull request at #126970. This integration allows tests to be automatically instantiated for Gaudi devices upon loading the relevant library. Building on this development, the current pull request extends the utility of these hooks by adapting selected CUDA tests to operate on Gaudi devices. Additionally, we have confirmed that these modifications do not interfere with the existing tests on CUDA devices.

Other accelerators can also extend the functionality by adding the device in the devices list. ( For eg: xpu )

CHANGES

Create a separate class for test functions running on CUDA devices
Extend the functionality of these tests to include HPUs
Use instantiate_device_type_tests with targeted attributes to generate device-specific test instances within the new classes
Apply skipIfHPU decorator to bypass tests that are not yet compatible with HPU devices

cc: @ankurneog , @EikanWang , @yanboliang , @guangyey

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 21, 2025

🔗 Helpful Links

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

Note: Links to docs will display an error until the docs builds have been completed.

❌ 12 New Failures

As of commit dba2f05 with merge base bd019c0 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@amathewc
Copy link
Contributor Author

@ankurneog , @EikanWang , @yanboliang , @guangyey : please review this PR.

@EikanWang EikanWang requested a review from yanboliang February 24, 2025 11:53
res = opt_func(a)
self.assertIsInstance(res, torch.Tensor)

# @unittest.skipIf(not TEST_CUDA, "requires cuda")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# @unittest.skipIf(not TEST_CUDA, "requires cuda")

self.assertEqual(res.device.index, 0)
self.assertEqual(counter.frame_count, 2)

def test_torch_device_python_type(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def test_torch_device_python_type(self):
def test_torch_device_python_type(self, device):

Comment on lines +11839 to +11840
@unittest.skipIf(not torch.cuda.is_available(), "Test requires CUDA.")
def test_symint_as_device_kwarg_non_strict_export(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this case cannot work well on HPU?

else:
return x - 1

x = torch.rand(4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The x is a CPU tensor. How does it verify the CUDA and HPU path?

Comment on lines +9259 to +9273
# FIXME(XuehaiPan): do not inline infinite generator if it does not raise errors in eager mode
def fn(x):
def gen():
while True:
yield x

return list(zip(range(10), gen()))

x = torch.randn([0, 1, 2, 3, 4, 5])
compiled_fn = torch.compile(fn, backend="eager", fullgraph=True)
with self.assertRaisesRegex(
torch._dynamo.exc.Unsupported, "infinite generator"
):
compiled_fn(x)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated code block.


def write_state(state):
torch.set_grad_enabled(state[0])
torch.set_grad_enabled(state[0]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
torch.set_grad_enabled(state[0]),
torch.set_grad_enabled(state[0])

torch.set_grad_enabled(state[0]),
torch.use_deterministic_algorithms(state[1])
torch._C._set_cublas_allow_tf32(state[2])
torch._C._set_cublas_allow_tf32(state[2]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
torch._C._set_cublas_allow_tf32(state[2]),
torch._C._set_cublas_allow_tf32(state[2])

torch.cuda.set_device(1)
return a + 1

with torch.cuda.device(0):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This case is device-specific. It should be decorated by requires_cuda.

_, ne = run(torch.ones(1))
self.assertFalse(ne)

def test_ne_operator_with_custom_ne(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto


torch.allclose(inp1_custom.grad, inp1_usual.grad)

def test_retain_grad(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 25, 2025
@amathewc amathewc closed this Mar 19, 2025
@amathewc
Copy link
Contributor Author

The review comments and merge conflicts will be addressed in a separate PR.

@amathewc amathewc deleted the dynamo_changes2 branch March 19, 2025 10:14
pytorchmergebot pushed a commit that referenced this pull request Apr 4, 2025
This PR is related to #145476 . That PR had two files (test_functions.py and test_misc.py) . test_functions was causing CI/rebase/merge issues and hence removed for now. This PR contains only test_misc.py.

This is a continuation of #144387 .

## MOTIVATION
We recently integrated support for Intel Gaudi devices (identified as 'hpu') into the common_device_type framework via the pull request at #126970. This integration allows tests to be automatically instantiated for Gaudi devices upon loading the relevant library. Building on this development, the current pull request extends the utility of these hooks by adapting selected CUDA tests to operate on Gaudi devices. Additionally, we have confirmed that these modifications do not interfere with the existing tests on CUDA devices.

Other accelerators can also extend the functionality by adding the device in the devices list. ( For eg: xpu )

## CHANGES
Create a separate class for test functions running on CUDA devices
Extend the functionality of these tests to include HPUs
Use instantiate_device_type_tests with targeted attributes to generate device-specific test instances within the new classes
Apply skipIfHPU decorator to bypass tests that are not yet compatible with HPU devices

PS: Most of these changes were initially part of #147609 , but closed that PR due to merge conflicts. The review comments were handled in this PR.

Pull Request resolved: #149499
Approved by: https://github.com/EikanWang, https://github.com/desertfire, https://github.com/cyyever
timocafe pushed a commit to timocafe/pytorch that referenced this pull request Apr 16, 2025
This PR is related to pytorch#145476 . That PR had two files (test_functions.py and test_misc.py) . test_functions was causing CI/rebase/merge issues and hence removed for now. This PR contains only test_misc.py.

This is a continuation of pytorch#144387 .

## MOTIVATION
We recently integrated support for Intel Gaudi devices (identified as 'hpu') into the common_device_type framework via the pull request at pytorch#126970. This integration allows tests to be automatically instantiated for Gaudi devices upon loading the relevant library. Building on this development, the current pull request extends the utility of these hooks by adapting selected CUDA tests to operate on Gaudi devices. Additionally, we have confirmed that these modifications do not interfere with the existing tests on CUDA devices.

Other accelerators can also extend the functionality by adding the device in the devices list. ( For eg: xpu )

## CHANGES
Create a separate class for test functions running on CUDA devices
Extend the functionality of these tests to include HPUs
Use instantiate_device_type_tests with targeted attributes to generate device-specific test instances within the new classes
Apply skipIfHPU decorator to bypass tests that are not yet compatible with HPU devices

PS: Most of these changes were initially part of pytorch#147609 , but closed that PR due to merge conflicts. The review comments were handled in this PR.

Pull Request resolved: pytorch#149499
Approved by: https://github.com/EikanWang, https://github.com/desertfire, https://github.com/cyyever
amathewc added a commit to amathewc/pytorch that referenced this pull request Apr 17, 2025
This PR is related to pytorch#145476 . That PR had two files (test_functions.py and test_misc.py) . test_functions was causing CI/rebase/merge issues and hence removed for now. This PR contains only test_misc.py.

This is a continuation of pytorch#144387 .

## MOTIVATION
We recently integrated support for Intel Gaudi devices (identified as 'hpu') into the common_device_type framework via the pull request at pytorch#126970. This integration allows tests to be automatically instantiated for Gaudi devices upon loading the relevant library. Building on this development, the current pull request extends the utility of these hooks by adapting selected CUDA tests to operate on Gaudi devices. Additionally, we have confirmed that these modifications do not interfere with the existing tests on CUDA devices.

Other accelerators can also extend the functionality by adding the device in the devices list. ( For eg: xpu )

## CHANGES
Create a separate class for test functions running on CUDA devices
Extend the functionality of these tests to include HPUs
Use instantiate_device_type_tests with targeted attributes to generate device-specific test instances within the new classes
Apply skipIfHPU decorator to bypass tests that are not yet compatible with HPU devices

PS: Most of these changes were initially part of pytorch#147609 , but closed that PR due to merge conflicts. The review comments were handled in this PR.

Pull Request resolved: pytorch#149499
Approved by: https://github.com/EikanWang, https://github.com/desertfire, https://github.com/cyyever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: dynamo open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants