Handle single-device models without hf_device_map after Transformers optimization#2401
Merged
Merged
Conversation
Signed-off-by: ZX-ModelCloud <[email protected]>
Signed-off-by: ZX-ModelCloud <[email protected]>
Signed-off-by: ZX-ModelCloud <[email protected]>
Contributor
|
@ZX-ModelCloud Also post the stacktrace of missing hf-device-map crash on main which this pr fixes. |
Contributor
|
@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 <[email protected]>
Signed-off-by: ZX-ModelCloud <[email protected]>
Signed-off-by: ZX-ModelCloud <[email protected]>
Signed-off-by: ZX-ModelCloud <[email protected]>
|
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
approved these changes
Jan 15, 2026
IlyasMoutawwakil
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for the fix !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?