-
Notifications
You must be signed in to change notification settings - Fork 618
Handle single-device models without hf_device_map after Transformers optimization
#2401
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
Handle single-device models without hf_device_map after Transformers optimization
#2401
Conversation
|
@ZX-ModelCloud Also post the stacktrace of missing hf-device-map crash on main which this pr fixes. |
|
@IlyasMoutawwakil PR to fix compat with latest transformers. hf_device_map is now nullable. Not sure if this going to be the norm or maybe a regression in transformers? |
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
|
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. |
IlyasMoutawwakil
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 a lot for the fix !
What does this PR do?
Do not use accelerate hooks if the device_map has only 1 device
This PR makes device map handling robust to the new Transformers behavior by:
Using
model.hf_device_mapwhen it is available (multi-device case)Falling back to inferring the runtime device for single-device models when it is not
The fallback relies on the fact that, in this code path, all model parameters are guaranteed to reside on the same device.
Stacktrace:
Before submitting
Who can review?