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
12c39e56
Unverified
Commit
12c39e56
authored
Apr 23, 2024
by
Jiewen Tan
Committed by
GitHub
Apr 23, 2024
Browse files
Fix use_cache for xla fsdp (#30353)
* Fix use_cache for xla fsdp * Fix linters
parent
b8b1e442
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
src/transformers/trainer.py
src/transformers/trainer.py
+6
-0
No files found.
src/transformers/trainer.py
View file @
12c39e56
...
@@ -1682,6 +1682,12 @@ class Trainer:
...
@@ -1682,6 +1682,12 @@ class Trainer:
)
)
fsdp_kwargs
=
self
.
args
.
xla_fsdp_config
fsdp_kwargs
=
self
.
args
.
xla_fsdp_config
if
self
.
args
.
fsdp_config
[
"xla_fsdp_grad_ckpt"
]:
if
self
.
args
.
fsdp_config
[
"xla_fsdp_grad_ckpt"
]:
if
model
.
config
.
use_cache
:
logger
.
warning_once
(
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
)
model
.
config
.
use_cache
=
False
# Apply gradient checkpointing to auto-wrapped sub-modules if specified
# Apply gradient checkpointing to auto-wrapped sub-modules if specified
def
auto_wrapper_callable
(
m
,
*
args
,
**
kwargs
):
def
auto_wrapper_callable
(
m
,
*
args
,
**
kwargs
):
target_cls
=
FSDP
if
not
self
.
is_fsdp_xla_v2_enabled
else
FSDPv2
target_cls
=
FSDP
if
not
self
.
is_fsdp_xla_v2_enabled
else
FSDPv2
...
...
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