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
d7a4f5be
Unverified
Commit
d7a4f5be
authored
Apr 03, 2023
by
Younes Belkada
Committed by
GitHub
Apr 03, 2023
Browse files
[`T5`] Enable naive Pipeline Parallelism training for T5 (#22535)
* enable PP for T5 * make fixup * fix failing tests
parent
cab048fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
src/transformers/models/mt5/modeling_mt5.py
src/transformers/models/mt5/modeling_mt5.py
+2
-0
src/transformers/models/t5/modeling_t5.py
src/transformers/models/t5/modeling_t5.py
+2
-0
No files found.
src/transformers/models/mt5/modeling_mt5.py
View file @
d7a4f5be
...
@@ -1778,6 +1778,8 @@ class MT5ForConditionalGeneration(MT5PreTrainedModel):
...
@@ -1778,6 +1778,8 @@ class MT5ForConditionalGeneration(MT5PreTrainedModel):
loss
=
None
loss
=
None
if
labels
is
not
None
:
if
labels
is
not
None
:
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
100
)
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
100
)
# move labels to correct device to enable PP
labels
=
labels
.
to
(
lm_logits
.
device
)
loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
lm_logits
.
size
(
-
1
)),
labels
.
view
(
-
1
))
loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
lm_logits
.
size
(
-
1
)),
labels
.
view
(
-
1
))
# TODO(thom): Add z_loss https://github.com/tensorflow/mesh/blob/fa19d69eafc9a482aff0b59ddd96b025c0cb207d/mesh_tensorflow/layers.py#L666
# TODO(thom): Add z_loss https://github.com/tensorflow/mesh/blob/fa19d69eafc9a482aff0b59ddd96b025c0cb207d/mesh_tensorflow/layers.py#L666
...
...
src/transformers/models/t5/modeling_t5.py
View file @
d7a4f5be
...
@@ -1746,6 +1746,8 @@ class T5ForConditionalGeneration(T5PreTrainedModel):
...
@@ -1746,6 +1746,8 @@ class T5ForConditionalGeneration(T5PreTrainedModel):
loss
=
None
loss
=
None
if
labels
is
not
None
:
if
labels
is
not
None
:
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
100
)
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
100
)
# move labels to correct device to enable PP
labels
=
labels
.
to
(
lm_logits
.
device
)
loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
lm_logits
.
size
(
-
1
)),
labels
.
view
(
-
1
))
loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
lm_logits
.
size
(
-
1
)),
labels
.
view
(
-
1
))
# TODO(thom): Add z_loss https://github.com/tensorflow/mesh/blob/fa19d69eafc9a482aff0b59ddd96b025c0cb207d/mesh_tensorflow/layers.py#L666
# TODO(thom): Add z_loss https://github.com/tensorflow/mesh/blob/fa19d69eafc9a482aff0b59ddd96b025c0cb207d/mesh_tensorflow/layers.py#L666
...
...
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