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

[Fix] make all tests pass on XPU #2427

Merged
merged 2 commits into from
Feb 9, 2024
Merged

Conversation

faaany
Copy link
Contributor

@faaany faaany commented Feb 8, 2024

What does this PR do?

When running make test on XPUs, I got the following test results:

FAILED tests/test_kwargs_handlers.py::KwargsHandlerTester::test_grad_scaler_kwargs - AttributeError: 'GradScaler' object has no attribute '_init_scale'
FAILED tests/test_optimizer.py::OptimizerTester::test_accelerated_optimizer_step_was_skipped - AssertionError: False is not true

The failed reason for these 2 tests is the same: XPU hasn't implemented torch.xpu.amp.GradScaler yet and in the current logic, self.scaler will be set to torch.cuda.amp.GradScaler as shown here.
To make the tests pass on XPU devices, we should skip these 2 tests on XPUs.

In addition to that, I noticed that there is no require_npu function in the testing.py. So I added it to the patch.

I am not sure whether it would be better to just use require_cuda instead of the combi of require_non_cpu and require_non_xpu. My goal is just to make all these tests work on XPU. Please let me know your thoughts. And if this patch is too small, just let me know as well. I can think about more tests related to XPU. Thanks a lot!

@muellerzr

@HuggingFaceDocBuilderDev

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.

Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Thanks, this skip format is indeed the right way!

@muellerzr muellerzr merged commit f75c624 into huggingface:main Feb 9, 2024
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants