-
Notifications
You must be signed in to change notification settings - Fork 31.4k
[tests] make TestDeepSpeedModelZoo device-agnostic
#31402
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
amyeroberts
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.
Thanks!
|
Let's get a second 👍 from @ydshieh the test master to confirm this is OK on our CI runs |
Sure! |
|
I further updated my code to get the real device count. But the CI seems to not use the latest transformers version. @ydshieh is this something intended? |
|
@faaany . It uses the latest dev. transformers version (i.e. this PR). The problem is that, some variables like Let me check what to do with it. |
|
Could you add if is_torch_available():
# Mappings from device names to callable functions to support device agnostic
# testing.
BACKEND_MANUAL_SEED = {"cuda": torch.cuda.manual_seed, "cpu": torch.manual_seed, "default": torch.manual_seed}
BACKEND_EMPTY_CACHE = {"cuda": torch.cuda.empty_cache, "cpu": None, "default": None}
BACKEND_DEVICE_COUNT = {"cuda": torch.cuda.device_count, "cpu": lambda: 0, "default": lambda: 1}to if is_torch_available():
# Mappings from device names to callable functions to support device agnostic
# testing.
BACKEND_MANUAL_SEED = {"cuda": torch.cuda.manual_seed, "cpu": torch.manual_seed, "default": torch.manual_seed}
BACKEND_EMPTY_CACHE = {"cuda": torch.cuda.empty_cache, "cpu": None, "default": None}
BACKEND_DEVICE_COUNT = {"cuda": torch.cuda.device_count, "cpu": lambda: 0, "default": lambda: 1}
else:
BACKEND_MANUAL_SEED = {"default": None}
BACKEND_EMPTY_CACHE = {"default": None}
BACKEND_DEVICE_COUNT = {"default": lambda: 0}and see how it goes? 🙏 thank you in advance |
|
@ydshieh yes, it works, thx for the suggestion! The CI still doesn't run through, but I think it is not caused by this PR. |
|
Yeah, rebase on main to include #31407 would make CI green. |
ydshieh
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.
Thank you !
|
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. |
What does this PR do?
This PR is to enable the
TestDeepSpeedModelZootests to work on a non-CUDA accelerator.@amyeroberts and @ydshieh