Unverified Commit ab19f907 authored by Younes Belkada's avatar Younes Belkada Committed by GitHub
Browse files

FIX / OPT: Fix OPT multi-GPU training for `OPTForQuestionAnswering` (#31092)

Update modeling_opt.py
parent 94d416f0
...@@ -1427,8 +1427,8 @@ class OPTForQuestionAnswering(OPTPreTrainedModel): ...@@ -1427,8 +1427,8 @@ class OPTForQuestionAnswering(OPTPreTrainedModel):
end_positions = end_positions.squeeze(-1) end_positions = end_positions.squeeze(-1)
# sometimes the start/end positions are outside our model inputs, we ignore these terms # sometimes the start/end positions are outside our model inputs, we ignore these terms
ignored_index = start_logits.size(1) ignored_index = start_logits.size(1)
start_positions = start_positions.clamp(0, ignored_index) start_positions = start_positions.clamp(0, ignored_index).to(logits.device)
end_positions = end_positions.clamp(0, ignored_index) end_positions = end_positions.clamp(0, ignored_index).to(logits.device)
loss_fct = CrossEntropyLoss(ignore_index=ignored_index) loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
start_loss = loss_fct(start_logits, start_positions) start_loss = loss_fct(start_logits, start_positions)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment