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
57b92bbf
Unverified
Commit
57b92bbf
authored
Apr 18, 2024
by
Zizhao Chen
Committed by
GitHub
Apr 18, 2024
Browse files
disable use_cache if using gradient checkpointing (#30320)
parent
68be1d3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
src/transformers/models/idefics2/modeling_idefics2.py
src/transformers/models/idefics2/modeling_idefics2.py
+6
-0
No files found.
src/transformers/models/idefics2/modeling_idefics2.py
View file @
57b92bbf
...
...
@@ -1581,6 +1581,12 @@ class Idefics2Model(Idefics2PreTrainedModel):
use_cache
=
use_cache
if
use_cache
is
not
None
else
self
.
config
.
use_cache
return_dict
=
return_dict
if
return_dict
is
not
None
else
self
.
config
.
use_return_dict
if
self
.
training
and
self
.
text_model
.
gradient_checkpointing
and
use_cache
:
logger
.
warning_once
(
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
)
use_cache
=
False
# retrieve input_ids and inputs_embeds
if
input_ids
is
not
None
:
batch_size
,
seq_length
=
input_ids
.
shape
...
...
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