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
7811bf7e
Unverified
Commit
7811bf7e
authored
Feb 27, 2023
by
Karim Foda
Committed by
GitHub
Feb 27, 2023
Browse files
Fix gradient checkpointing bug in gptneox (#21815)
* Fix gradient checkpointing bug in gptneox * Remove use_cache block
parent
0c7f93f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/transformers/models/gpt_neox/modeling_gpt_neox.py
src/transformers/models/gpt_neox/modeling_gpt_neox.py
+7
-5
No files found.
src/transformers/models/gpt_neox/modeling_gpt_neox.py
View file @
7811bf7e
...
@@ -500,6 +500,13 @@ class GPTNeoXModel(GPTNeoXPreTrainedModel):
...
@@ -500,6 +500,13 @@ class GPTNeoXModel(GPTNeoXPreTrainedModel):
hidden_states
=
inputs_embeds
hidden_states
=
inputs_embeds
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
presents
=
()
if
use_cache
else
None
presents
=
()
if
use_cache
else
None
all_attentions
=
()
if
output_attentions
else
None
all_attentions
=
()
if
output_attentions
else
None
all_hidden_states
=
()
if
output_hidden_states
else
None
all_hidden_states
=
()
if
output_hidden_states
else
None
...
@@ -508,11 +515,6 @@ class GPTNeoXModel(GPTNeoXPreTrainedModel):
...
@@ -508,11 +515,6 @@ class GPTNeoXModel(GPTNeoXPreTrainedModel):
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
if
self
.
gradient_checkpointing
and
self
.
training
:
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
create_custom_forward
(
module
):
def
custom_forward
(
*
inputs
):
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