From a3b1effcda84caeb180427b1346d0212841418f6 Mon Sep 17 00:00:00 2001 From: Rock Chen Date: Thu, 20 Aug 2026 15:35:28 +0800 Subject: [PATCH] convert: fix get block count error for Nemotron 3 Ultra (#27101) * convert: fix get block count error for Nemotron Signed-off-by: Rock Chen * fix this in NemotronHModel.__init__ instead. This reverts commit ca689cbc8792ba69ea1fd5d8b3ae0485c47536ec. --------- Signed-off-by: Rock Chen --- conversion/nemotron.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conversion/nemotron.py b/conversion/nemotron.py index 3e37c7b46..e5d167185 100644 --- a/conversion/nemotron.py +++ b/conversion/nemotron.py @@ -207,7 +207,9 @@ class NemotronHModel(GraniteHybridModel): # calling the parent __init__. This is because the parent constructor # uses self.model_arch to build the tensor name map, and all MoE-specific # mappings would be missed if it were called with the default non-MoE arch. - hparams = ModelBase.load_hparams(args[0], self.is_mistral_format) + hparams = kwargs.pop("hparams", None) + if hparams is None: + hparams = ModelBase.load_hparams(args[0], self.is_mistral_format) has_moe_params = ( "num_experts_per_tok" in hparams or (isinstance(hparams.get("llm_config"), dict) and "num_experts_per_tok" in hparams["llm_config"]) @@ -215,8 +217,11 @@ class NemotronHModel(GraniteHybridModel): if has_moe_params: self.model_arch = gguf.MODEL_ARCH.NEMOTRON_H_MOE self.is_moe = True + layers_block_type = hparams.get("layers_block_type") + if layers_block_type is not None: + hparams["num_hidden_layers"] = len(layers_block_type) - super().__init__(*args, **kwargs) + super().__init__(*args, hparams=hparams, **kwargs) # Save the top-level head_dim for later self.head_dim = self.hparams.get("head_dim", self.hparams.get("attention_head_dim"))