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
6af3ce77
Unverified
Commit
6af3ce77
authored
Dec 15, 2023
by
Sanchit Gandhi
Committed by
GitHub
Dec 15, 2023
Browse files
[Flax LLaMA] Fix attn dropout (#28059)
parent
7e876dca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
src/transformers/models/llama/modeling_flax_llama.py
src/transformers/models/llama/modeling_flax_llama.py
+6
-0
No files found.
src/transformers/models/llama/modeling_flax_llama.py
View file @
6af3ce77
...
@@ -289,6 +289,10 @@ class FlaxLlamaAttention(nn.Module):
...
@@ -289,6 +289,10 @@ class FlaxLlamaAttention(nn.Module):
attention_mask
=
jnp
.
broadcast_to
(
jnp
.
expand_dims
(
attention_mask
,
axis
=
(
-
3
,
-
2
)),
causal_mask
.
shape
)
attention_mask
=
jnp
.
broadcast_to
(
jnp
.
expand_dims
(
attention_mask
,
axis
=
(
-
3
,
-
2
)),
causal_mask
.
shape
)
attention_mask
=
combine_masks
(
attention_mask
,
causal_mask
)
attention_mask
=
combine_masks
(
attention_mask
,
causal_mask
)
dropout_rng
=
None
if
not
deterministic
and
self
.
config
.
attention_dropout
>
0.0
:
dropout_rng
=
self
.
make_rng
(
"dropout"
)
# During fast autoregressive decoding, we feed one position at a time,
# During fast autoregressive decoding, we feed one position at a time,
# and cache the keys and values step by step.
# and cache the keys and values step by step.
if
self
.
has_variable
(
"cache"
,
"cached_key"
)
or
init_cache
:
if
self
.
has_variable
(
"cache"
,
"cached_key"
)
or
init_cache
:
...
@@ -307,6 +311,8 @@ class FlaxLlamaAttention(nn.Module):
...
@@ -307,6 +311,8 @@ class FlaxLlamaAttention(nn.Module):
query
,
query
,
key
,
key
,
bias
=
attention_bias
,
bias
=
attention_bias
,
dropout_rng
=
dropout_rng
,
dropout_rate
=
self
.
config
.
attention_dropout
,
deterministic
=
deterministic
,
deterministic
=
deterministic
,
dtype
=
attention_dtype
,
dtype
=
attention_dtype
,
)
)
...
...
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