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
f3c75f8b
Unverified
Commit
f3c75f8b
authored
Mar 06, 2023
by
Srimanth Agastyaraju
Committed by
GitHub
Mar 06, 2023
Browse files
[Generate] Fix gradient_checkpointing and use_cache bug for BLOOM (#21956)
Step 1 - Change use_cache fix
parent
934d0b8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/transformers/models/bloom/modeling_bloom.py
src/transformers/models/bloom/modeling_bloom.py
+7
-5
No files found.
src/transformers/models/bloom/modeling_bloom.py
View file @
f3c75f8b
...
...
@@ -732,6 +732,13 @@ class BloomModel(BloomPreTrainedModel):
all_self_attentions
=
()
if
output_attentions
else
None
all_hidden_states
=
()
if
output_hidden_states
else
None
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
# Compute alibi tensor: check build_alibi_tensor documentation
seq_length_with_past
=
seq_length
past_key_values_length
=
0
...
...
@@ -756,11 +763,6 @@ class BloomModel(BloomPreTrainedModel):
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
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
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