Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
838d141f
Unverified
Commit
838d141f
authored
Aug 09, 2024
by
Raushan Turganbay
Committed by
GitHub
Aug 09, 2024
Browse files
Gemma2: fix FA2 generation (#32553)
fix FA2
parent
85817d98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
src/transformers/models/gemma2/modeling_gemma2.py
src/transformers/models/gemma2/modeling_gemma2.py
+5
-1
No files found.
src/transformers/models/gemma2/modeling_gemma2.py
View file @
838d141f
...
@@ -1093,7 +1093,11 @@ class Gemma2ForCausalLM(Gemma2PreTrainedModel):
...
@@ -1093,7 +1093,11 @@ class Gemma2ForCausalLM(Gemma2PreTrainedModel):
# The clone here is for the same reason as for `position_ids`.
# The clone here is for the same reason as for `position_ids`.
model_inputs
=
{
"input_ids"
:
input_ids
.
clone
(
memory_format
=
torch
.
contiguous_format
),
"inputs_embeds"
:
None
}
model_inputs
=
{
"input_ids"
:
input_ids
.
clone
(
memory_format
=
torch
.
contiguous_format
),
"inputs_embeds"
:
None
}
if
isinstance
(
past_key_values
,
HybridCache
)
and
attention_mask
.
ndim
==
2
:
if
(
isinstance
(
past_key_values
,
HybridCache
)
and
attention_mask
.
ndim
==
2
and
not
self
.
config
.
_attn_implementation
==
"flash_attention_2"
):
if
model_inputs
[
"inputs_embeds"
]
is
not
None
:
if
model_inputs
[
"inputs_embeds"
]
is
not
None
:
batch_size
,
sequence_length
,
_
=
model_inputs
[
"inputs_embeds"
].
shape
batch_size
,
sequence_length
,
_
=
model_inputs
[
"inputs_embeds"
].
shape
device
=
model_inputs
[
"inputs_embeds"
].
device
device
=
model_inputs
[
"inputs_embeds"
].
device
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment