Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sequence parallel get labels #1352

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions swift/trainers/trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ def compute_loss(self, model, inputs, return_outputs=None):
else:
loss = outputs['loss'] if isinstance(outputs, dict) else outputs[0]

if labels is None:
labels = inputs['labels']

if self.sequence_parallel_size > 1:
from swift.trainers.xtuner import reduce_xtuner_sequence_parallel_loss
loss = reduce_xtuner_sequence_parallel_loss(loss, labels)

if labels is None:
labels = inputs['labels']
if self.is_encoder_decoder:
preds = outputs.logits.argmax(dim=2)[..., :]
labels = labels[..., :]
Expand Down
Loading