Skip to content
Open
Changes from all commits
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
3 changes: 3 additions & 0 deletions mova/engine/trainer/accelerate/accelerate_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import os, re
import torch
import torch_npu
from tqdm import tqdm

try:
Expand Down Expand Up @@ -411,6 +412,8 @@ def train(self):
loss = loss_dict["loss"]

self.accelerator.backward(loss)
# Synchronize NPU stream to avoid async ordering issues with DP replicate training.
torch_npu.npu.current_stream().synchronize()

if self.gradient_clip_norm > 0:
if self.accelerator.sync_gradients:
Expand Down