Skip to content

Commit

Permalink
Gemma2: fix FA2 generation (#32553)
Browse files Browse the repository at this point in the history
fix FA2
  • Loading branch information
zucchini-nlp authored and ArthurZucker committed Aug 20, 2024
1 parent 984bc11 commit 679e235
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/transformers/models/gemma2/modeling_gemma2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,9 @@ def prepare_inputs_for_generation(
model_inputs = {"input_ids": input_ids.clone(memory_format=torch.contiguous_format)}

if isinstance(past_key_values, HybridCache) and attention_mask.ndim == 2:
if inputs_embeds is not None:
batch_size, sequence_length = inputs_embeds.shape
device = inputs_embeds.device
if model_inputs["inputs_embeds"] is not None:
batch_size, sequence_length, _ = model_inputs["inputs_embeds"].shape
device = model_inputs["inputs_embeds"].device
else:
batch_size, sequence_length = input_ids.shape
device = input_ids.device
Expand Down

0 comments on commit 679e235

Please sign in to comment.