fix model parallel device mismatch issue in create_bidirectional_mask#46221
Merged
Conversation
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
vasqu
approved these changes
May 26, 2026
Contributor
vasqu
left a comment
There was a problem hiding this comment.
Thanks! This indeed is an edge case we never considered before
yuchenxie4645
pushed a commit
to yuchenxie4645/transformers
that referenced
this pull request
May 28, 2026
…k` (huggingface#46221) Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
kashif
pushed a commit
to kashif/transformers
that referenced
this pull request
Jun 1, 2026
…k` (huggingface#46221) Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
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.
In
create_bidirectional_maskfunc, we need to keep the device align with input_embeds.e.g. in this case:
tests/models/t5gemma/test_modeling_t5gemma.py::T5GemmaModelTest::test_model_parallel_beam_search,encoder_hidden_statesmay live on a different device thaninputs_embeds(e.g. cross-attention from a decoder to encoder states) in model parallel scene. I think it may be a common bug for decoder-encoder model family. And this PR tries to solve it.@Cyrilvallez @vasqu pls help review, thx!