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
de496ef0
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "207e25035a1b3821d0c33f788561dd749c280a75"
Unverified
Commit
de496ef0
authored
Mar 06, 2023
by
Karim Foda
Committed by
GitHub
Mar 06, 2023
Browse files
Fix gradient checkpointing bug in Codegen (#21979)
parent
4a545d18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/transformers/models/codegen/modeling_codegen.py
src/transformers/models/codegen/modeling_codegen.py
+8
-6
No files found.
src/transformers/models/codegen/modeling_codegen.py
View file @
de496ef0
...
@@ -539,6 +539,14 @@ class CodeGenModel(CodeGenPreTrainedModel):
...
@@ -539,6 +539,14 @@ class CodeGenModel(CodeGenPreTrainedModel):
output_shape
=
input_shape
+
(
hidden_states
.
size
(
-
1
),)
output_shape
=
input_shape
+
(
hidden_states
.
size
(
-
1
),)
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
presents
=
()
if
use_cache
else
None
presents
=
()
if
use_cache
else
None
all_self_attentions
=
()
if
output_attentions
else
None
all_self_attentions
=
()
if
output_attentions
else
None
all_hidden_states
=
()
if
output_hidden_states
else
None
all_hidden_states
=
()
if
output_hidden_states
else
None
...
@@ -547,12 +555,6 @@ class CodeGenModel(CodeGenPreTrainedModel):
...
@@ -547,12 +555,6 @@ class CodeGenModel(CodeGenPreTrainedModel):
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_once
(
"`use_cache=True` is incompatible with `config.gradient_checkpointing=True`. 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