[Models][Gemma4] Prevent GPU/CPU sync in embed_input_ids (#39234)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
@@ -1254,9 +1254,10 @@ class Gemma4ForConditionalGeneration(
|
|||||||
# computation (using token_type_ids == 0 as text_mask).
|
# computation (using token_type_ids == 0 as text_mask).
|
||||||
# Replicate this: map image token positions to token 0.
|
# Replicate this: map image token positions to token 0.
|
||||||
if is_multimodal is not None:
|
if is_multimodal is not None:
|
||||||
is_multimodal = is_multimodal.to(input_ids.device)
|
|
||||||
ple_input_ids = torch.where(
|
ple_input_ids = torch.where(
|
||||||
is_multimodal, torch.zeros_like(input_ids), input_ids
|
is_multimodal.to(input_ids.device, non_blocking=True),
|
||||||
|
torch.zeros_like(input_ids),
|
||||||
|
input_ids,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
ple_input_ids = input_ids
|
ple_input_ids = input_ids
|
||||||
|
|||||||
Reference in New Issue
Block a user