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
4edfd2d4
Unverified
Commit
4edfd2d4
authored
Mar 02, 2023
by
saswatmeher
Committed by
GitHub
Mar 01, 2023
Browse files
Fix Gradient checkpointing bug BigBird (#21882)
Co-authored-by:
saswatmeher
<
saswatmeher@cse.iitb.ac.in
>
parent
269b0549
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/transformers/models/big_bird/modeling_big_bird.py
src/transformers/models/big_bird/modeling_big_bird.py
+7
-5
No files found.
src/transformers/models/big_bird/modeling_big_bird.py
View file @
4edfd2d4
...
...
@@ -1592,6 +1592,13 @@ class BigBirdEncoder(nn.Module):
all_self_attentions
=
()
if
output_attentions
else
None
all_cross_attentions
=
()
if
output_attentions
and
self
.
config
.
add_cross_attention
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
next_decoder_cache
=
()
if
use_cache
else
None
for
i
,
layer_module
in
enumerate
(
self
.
layer
):
...
...
@@ -1602,11 +1609,6 @@ class BigBirdEncoder(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 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