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
0ce5236d
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "47a551d17b6ed2eaf03301f049006d559fca5cf3"
Unverified
Commit
0ce5236d
authored
Mar 06, 2023
by
Karim Foda
Committed by
GitHub
Mar 06, 2023
Browse files
Fix gradient checkpointing bug in ESM (#21980)
parent
de496ef0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
src/transformers/models/esm/modeling_esm.py
src/transformers/models/esm/modeling_esm.py
+7
-6
No files found.
src/transformers/models/esm/modeling_esm.py
View file @
0ce5236d
...
...
@@ -583,6 +583,13 @@ class EsmEncoder(nn.Module):
output_hidden_states
=
False
,
return_dict
=
True
,
):
if
self
.
gradient_checkpointing
and
self
.
training
:
if
use_cache
:
logger
.
warning_once
(
"`use_cache=True` is incompatible with `config.gradient_checkpointing=True`. Setting "
"`use_cache=False`..."
)
use_cache
=
False
all_hidden_states
=
()
if
output_hidden_states
else
None
all_self_attentions
=
()
if
output_attentions
else
None
all_cross_attentions
=
()
if
output_attentions
and
self
.
config
.
add_cross_attention
else
None
...
...
@@ -596,12 +603,6 @@ class EsmEncoder(nn.Module):
past_key_value
=
past_key_values
[
i
]
if
past_key_values
is
not
None
else
None
if
self
.
gradient_checkpointing
and
self
.
training
:
if
use_cache
:
logger
.
warning_once
(
"`use_cache=True` is incompatible with `config.gradient_checkpointing=True`. Setting "
"`use_cache=False`..."
)
use_cache
=
False
def
create_custom_forward
(
module
):
def
custom_forward
(
*
inputs
):
...
...
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