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
0224aaf6
Unverified
Commit
0224aaf6
authored
Apr 11, 2023
by
Mayank Agarwal
Committed by
GitHub
Apr 11, 2023
Browse files
Enable naive Pipeline Parallelism training for Gpt neox japanese and san japanese (#22702)
Move labels to same device as logits
parent
28c19ab5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
src/transformers/models/gpt_neox_japanese/modeling_gpt_neox_japanese.py
...rs/models/gpt_neox_japanese/modeling_gpt_neox_japanese.py
+3
-0
src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py
...ormers/models/gptsan_japanese/modeling_gptsan_japanese.py
+3
-0
No files found.
src/transformers/models/gpt_neox_japanese/modeling_gpt_neox_japanese.py
View file @
0224aaf6
...
@@ -682,6 +682,9 @@ class GPTNeoXJapaneseForCausalLM(GPTNeoXJapanesePreTrainedModel):
...
@@ -682,6 +682,9 @@ class GPTNeoXJapaneseForCausalLM(GPTNeoXJapanesePreTrainedModel):
lm_loss
=
None
lm_loss
=
None
if
labels
is
not
None
:
if
labels
is
not
None
:
# move labels to correct device to enable model parallelism
labels
=
labels
.
to
(
lm_logits
.
device
)
# we are doing next-token prediction; shift prediction scores and input ids by one
# we are doing next-token prediction; shift prediction scores and input ids by one
shift_logits
=
lm_logits
[:,
:
-
1
,
:].
contiguous
()
shift_logits
=
lm_logits
[:,
:
-
1
,
:].
contiguous
()
labels
=
labels
[:,
1
:].
contiguous
()
labels
=
labels
[:,
1
:].
contiguous
()
...
...
src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py
View file @
0224aaf6
...
@@ -1236,6 +1236,9 @@ class GPTSanJapaneseForConditionalGeneration(GPTSanJapanesePreTrainedModel):
...
@@ -1236,6 +1236,9 @@ class GPTSanJapaneseForConditionalGeneration(GPTSanJapanesePreTrainedModel):
router_probs
=
None
router_probs
=
None
aux_loss
=
None
aux_loss
=
None
if
labels
is
not
None
:
if
labels
is
not
None
:
# move labels to correct device to enable model parallelism
labels
=
labels
.
to
(
lm_logits
.
device
)
loss_fct
=
nn
.
CrossEntropyLoss
(
ignore_index
=-
100
)
loss_fct
=
nn
.
CrossEntropyLoss
(
ignore_index
=-
100
)
if
output_router_logits
:
if
output_router_logits
:
...
...
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