mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-08-01 05:36:10 +08:00
[train] Fix hyper parallel tail accumulation loss scaling (#10705)
Co-authored-by: wcrzlh <weichaoran@huawei.com>
This commit is contained in:
@@ -361,7 +361,12 @@ class HyperParallelTrainer(CustomSeq2SeqTrainer):
|
||||
loss = loss.mean()
|
||||
|
||||
if not getattr(self, "model_accepts_loss_kwargs", False) and getattr(self, "compute_loss_func", None) is None:
|
||||
loss = loss / self.args.gradient_accumulation_steps
|
||||
accumulation_steps = getattr(
|
||||
self,
|
||||
"current_gradient_accumulation_steps",
|
||||
self.args.gradient_accumulation_steps,
|
||||
)
|
||||
loss = loss / accumulation_steps
|
||||
|
||||
self.accelerator.backward(loss)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user