From 62b08f4d7a3e54780ad249aefebeeb9ad4a84e40 Mon Sep 17 00:00:00 2001 From: Kartik Gulia Date: Wed, 19 Aug 2026 10:02:27 +0530 Subject: [PATCH 1/2] convert: fix Nemotron-H LoRA GGUF conversion --- conversion/nemotron.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/conversion/nemotron.py b/conversion/nemotron.py index 3e37c7b469f5..ccd86f52cf5d 100644 --- a/conversion/nemotron.py +++ b/conversion/nemotron.py @@ -1,5 +1,7 @@ from __future__ import annotations +import json + from typing import Any, Callable, Iterable, TYPE_CHECKING import torch @@ -207,7 +209,11 @@ def __init__(self, *args, **kwargs): # 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) + # LoRA conversion passes AutoConfig-derived hparams, which may omit required + # fields such as num_hidden_layers. Load complete config.json directly. + with open(args[0] / "config.json", "r", encoding="utf-8") as f: + hparams = json.load(f) + kwargs["hparams"] = hparams 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"]) @@ -293,6 +299,10 @@ def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Ca ) if not keep: return None + # PEFT names adapter tensors using model.layers.*, while Nemotron-H checkpoints + # and the GGUF tensor map use backbone.layers.* + if name.startswith("model.layers.") and ".mixer." in name: + name = name.replace("model.layers.", "backbone.layers.", 1) return super().filter_tensors((name, gen)) def prepare_metadata(self, vocab_only: bool): From 84902e470b7b939f9a22e4740085241e1852a4f1 Mon Sep 17 00:00:00 2001 From: Kartik Gulia Date: Mon, 24 Aug 2026 10:24:09 +0530 Subject: [PATCH 2/2] Removed redundant JSON import. --- conversion/nemotron.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/conversion/nemotron.py b/conversion/nemotron.py index 4687f15f06c2..19892ad902b1 100644 --- a/conversion/nemotron.py +++ b/conversion/nemotron.py @@ -1,7 +1,5 @@ from __future__ import annotations -import json - from typing import Any, Callable, Iterable, TYPE_CHECKING import torch