convert: fix get block count error for Nemotron

Signed-off-by: Rock Chen <rockchen.tw@gmail.com>
This commit is contained in:
Rock Chen
2026-08-15 00:17:16 +08:00
parent 1692f9e50b
commit ca689cbc87
2 changed files with 11 additions and 1 deletions
+3 -1
View File
@@ -1126,6 +1126,8 @@ class ModelBase:
except KeyError:
raise NotImplementedError(f'Architecture {arch!r} not supported!') from None
def get_block_count(self) -> Any:
return self.find_hparam(["n_layers", "num_hidden_layers", "n_layer", "num_layers"])
class TextModel(ModelBase):
model_type = ModelType.TEXT
@@ -1142,7 +1144,7 @@ class TextModel(ModelBase):
# move the text_config to the root level
self.hparams = {**self.hparams, **self.hparams["text_config"]}
self.block_count = self.find_hparam(["n_layers", "num_hidden_layers", "n_layer", "num_layers"])
self.block_count = self.get_block_count()
self.tensor_map = gguf.get_tensor_name_map(self.model_arch, self.block_count)
self.rope_parameters = self.hparams.get("rope_parameters", self.hparams.get("rope_scaling")) or {}
+8
View File
@@ -497,3 +497,11 @@ class NemotronHModel(GraniteHybridModel):
experts = [k for d in self._experts for k in d.keys()]
if len(experts) > 0:
raise ValueError(f"Unprocessed experts: {experts}")
def get_block_count(self) -> Any:
types = self.find_hparam(["layers_block_type"], True)
if types is not None:
return len(types)
return super().get_block_count()