|
|
@@ -98,13 +98,13 @@ def train_epoch(epoch, loader, iters, teacher_model, lm_config_student, start_st
|
|
|
scaler.update()
|
|
|
optimizer.zero_grad(set_to_none=True)
|
|
|
|
|
|
- if step % args.log_interval == 0 or step == iters - 1:
|
|
|
+ if step % args.log_interval == 0 or step == iters:
|
|
|
spend_time = time.time() - start_time
|
|
|
current_loss = loss.item() * args.accumulation_steps
|
|
|
current_ce_loss = ce_loss_raw.item()
|
|
|
current_aux_loss = res.aux_loss.item() if lm_config_student.use_moe else 0.0
|
|
|
current_lr = optimizer.param_groups[-1]['lr']
|
|
|
- eta_min = spend_time / (step + 1) * iters // 60 - spend_time // 60
|
|
|
+ eta_min = spend_time / step * iters // 60 - spend_time // 60
|
|
|
|
|
|
Logger(f'Epoch:[{epoch + 1}/{args.epochs}]({step}/{iters}), loss: {current_loss:.4f}, ce: {current_ce_loss:.4f}, aux_loss: {current_aux_loss:.4f}, distill: {distill_loss.item():.4f}, learning_rate: {current_lr:.8f}, epoch_time: {eta_min:.3f}min')
|
|
|
|
|
|
@@ -118,7 +118,7 @@ def train_epoch(epoch, loader, iters, teacher_model, lm_config_student, start_st
|
|
|
"epoch_time": eta_min
|
|
|
})
|
|
|
|
|
|
- if (step % args.save_interval == 0 or step == iters - 1) and is_main_process():
|
|
|
+ if (step % args.save_interval == 0 or step == iters) and is_main_process():
|
|
|
model.eval()
|
|
|
moe_suffix = '_moe' if lm_config_student.use_moe else ''
|
|
|
ckp = f'{args.save_dir}/{args.save_weight}_{lm_config_student.hidden_size}{moe_suffix}.pth'
|