Skip to content

Commit

Permalink
FIX / OPT: Fix OPT multi-GPU training for OPTForQuestionAnswering (h…
Browse files Browse the repository at this point in the history
…uggingface#31092)

Update modeling_opt.py
  • Loading branch information
younesbelkada authored May 28, 2024
1 parent 94d416f commit ab19f90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/models/opt/modeling_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,8 @@ def forward(
end_positions = end_positions.squeeze(-1)
# sometimes the start/end positions are outside our model inputs, we ignore these terms
ignored_index = start_logits.size(1)
start_positions = start_positions.clamp(0, ignored_index)
end_positions = end_positions.clamp(0, ignored_index)
start_positions = start_positions.clamp(0, ignored_index).to(logits.device)
end_positions = end_positions.clamp(0, ignored_index).to(logits.device)

loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
start_loss = loss_fct(start_logits, start_positions)
Expand Down

0 comments on commit ab19f90

Please sign in to comment.