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
2e37ef35
"tests/models/roberta/test_tokenization_roberta.py" did not exist on "7e98e211f0e86e414b22946bd89391e49d2ea900"
Unverified
Commit
2e37ef35
authored
Jun 06, 2022
by
Jason Phang
Committed by
GitHub
Jun 06, 2022
Browse files
Remove RuntimeErrors for NaN-checking in 20B (#17563)
parent
f6ad0e05
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
6 deletions
+0
-6
src/transformers/models/gpt_neox/modeling_gpt_neox.py
src/transformers/models/gpt_neox/modeling_gpt_neox.py
+0
-6
No files found.
src/transformers/models/gpt_neox/modeling_gpt_neox.py
View file @
2e37ef35
...
...
@@ -193,8 +193,6 @@ class GPTNeoXAttention(nn.Module):
query
=
query
.
view
(
batch_size
*
num_attention_heads
,
query_length
,
attn_head_size
)
key
=
key
.
view
(
batch_size
*
num_attention_heads
,
key_length
,
attn_head_size
)
attn_scores
=
torch
.
einsum
(
"bik,bjk->bij"
,
query
,
key
)
/
self
.
norm_factor
if
torch
.
isnan
(
attn_scores
).
any
():
raise
RuntimeError
()
attn_scores
=
attn_scores
.
view
(
batch_size
,
num_attention_heads
,
query_length
,
key_length
)
attn_scores
=
torch
.
where
(
causal_mask
,
attn_scores
,
self
.
masked_bias
.
to
(
attn_scores
.
dtype
))
...
...
@@ -204,8 +202,6 @@ class GPTNeoXAttention(nn.Module):
attn_scores
=
attn_scores
+
attention_mask
attn_weights
=
nn
.
functional
.
softmax
(
attn_scores
,
dim
=-
1
)
if
torch
.
isnan
(
attn_weights
).
any
():
raise
RuntimeError
()
attn_weights
=
attn_weights
.
to
(
value
.
dtype
)
# Mask heads if we want to
...
...
@@ -213,8 +209,6 @@ class GPTNeoXAttention(nn.Module):
attn_weights
=
attn_weights
*
head_mask
attn_output
=
torch
.
matmul
(
attn_weights
,
value
)
if
torch
.
isnan
(
attn_output
).
any
():
raise
RuntimeError
()
return
attn_output
,
attn_weights
...
...
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