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
d0876a09
"tests/vit/test_modeling_vit.py" did not exist on "0167edc8549b8c8b01fcc669d0da7ea41903b244"
Unverified
Commit
d0876a09
authored
Mar 13, 2023
by
Karim Foda
Committed by
GitHub
Mar 13, 2023
Browse files
Fix gradient checkpointing bug in xglm (#22127)
parent
0c883766
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/transformers/models/xglm/modeling_xglm.py
src/transformers/models/xglm/modeling_xglm.py
+8
-6
No files found.
src/transformers/models/xglm/modeling_xglm.py
View file @
d0876a09
...
...
@@ -714,6 +714,14 @@ class XGLMModel(XGLMPreTrainedModel):
hidden_states
=
nn
.
functional
.
dropout
(
hidden_states
,
p
=
float
(
self
.
dropout
),
training
=
self
.
training
)
if
self
.
gradient_checkpointing
and
self
.
training
:
if
use_cache
:
logger
.
warning_once
(
"`use_cache = True` is incompatible with gradient checkpointing`. Setting `use_cache ="
" False`..."
)
use_cache
=
False
# decoder layers
all_hidden_states
=
()
if
output_hidden_states
else
None
all_self_attns
=
()
if
output_attentions
else
None
...
...
@@ -739,12 +747,6 @@ class XGLMModel(XGLMPreTrainedModel):
past_key_value
=
past_key_values
[
idx
]
if
past_key_values
is
not
None
else
None
if
self
.
gradient_checkpointing
and
self
.
training
:
if
use_cache
:
logger
.
warning
(
"`use_cache = True` is incompatible with gradient checkpointing`. 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