From afb35a10edc6e53d6c7c712808a406addf6948ba Mon Sep 17 00:00:00 2001 From: Lysandre Debut Date: Mon, 2 Jun 2025 17:16:31 +0200 Subject: [PATCH] Num parameters in model.safetensors.index.json (#38531) Num parameters in index.json --- src/transformers/modeling_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index c3c4c75750c..480e6f3f3f3 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -3750,7 +3750,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, PushToHubMixin, PeftAdapterMi index = None if state_dict_split.is_sharded: index = { - "metadata": state_dict_split.metadata, + "metadata": {"total_parameters": self.num_parameters(), **state_dict_split.metadata}, "weight_map": state_dict_split.tensor_to_filename, }