Skip to content

Do not use accelerate hooks if the device_map has only 1 device#43019

Merged
Cyrilvallez merged 5 commits intomainfrom
no-device-map-hooks
Dec 23, 2025
Merged

Do not use accelerate hooks if the device_map has only 1 device#43019
Cyrilvallez merged 5 commits intomainfrom
no-device-map-hooks

Conversation

@Cyrilvallez
Copy link
Member

@Cyrilvallez Cyrilvallez commented Dec 23, 2025

What does this PR do?

As per the title. In case of a single device, it's much easier and safer to simply move everything to the correct device, rather than to add hooks so that non-persistent buffers etc can be correctly used

From my benchmarks, this ends up being more efficient at forward-time, as expected (not crazy acceleration, but it's free anyway)

@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.

@github-actions
Copy link
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43019&sha=a8e1cd

@Cyrilvallez Cyrilvallez merged commit 315dcbe into main Dec 23, 2025
24 of 26 checks passed
@Cyrilvallez Cyrilvallez deleted the no-device-map-hooks branch December 23, 2025 12:21
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
…ingface#43019)

* unique device

* comment

* fix

* simplify and add mismatched

* style
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.

2 participants