From bbd300a91184d09dec56a3b06734051dbd5812e4 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 20 五月 2024 15:27:24 +0800
Subject: [PATCH] ds

---
 funasr/train_utils/average_nbest_models.py |    4 ++--
 funasr/bin/train_ds.py                     |    4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/funasr/bin/train_ds.py b/funasr/bin/train_ds.py
index 03cb184..a4ae11b 100644
--- a/funasr/bin/train_ds.py
+++ b/funasr/bin/train_ds.py
@@ -198,7 +198,9 @@
         trainer.train_loss_avg = 0.0
 
     if trainer.rank == 0:
-        average_checkpoints(trainer.output_dir, trainer.avg_nbest_model)
+        average_checkpoints(
+            trainer.output_dir, trainer.avg_nbest_model, use_deepspeed=trainer.use_deepspeed
+        )
 
     trainer.close()
 
diff --git a/funasr/train_utils/average_nbest_models.py b/funasr/train_utils/average_nbest_models.py
index 8553baa..20da130 100644
--- a/funasr/train_utils/average_nbest_models.py
+++ b/funasr/train_utils/average_nbest_models.py
@@ -16,7 +16,7 @@
 from functools import cmp_to_key
 
 
-def _get_checkpoint_paths(output_dir: str, last_n: int = 5, use_deepspeed=False):
+def _get_checkpoint_paths(output_dir: str, last_n: int = 5, use_deepspeed=False, **kwargs):
     """
     Get the paths of the last 'last_n' checkpoints by parsing filenames
     in the output directory.
@@ -55,7 +55,7 @@
     Average the last 'last_n' checkpoints' model state_dicts.
     If a tensor is of type torch.int, perform sum instead of average.
     """
-    checkpoint_paths = _get_checkpoint_paths(output_dir, last_n)
+    checkpoint_paths = _get_checkpoint_paths(output_dir, last_n, **kwargs)
     print(f"average_checkpoints: {checkpoint_paths}")
     state_dicts = []
 

--
Gitblit v1.9.1