Skip to content

convert: fix Nemotron-H LoRA GGUF conversion - #27356

Merged
CISC merged 3 commits into
ggml-org:masterfrom
frozenblade1224:nemotron-lora-conversion-fix
Aug 27, 2026
Merged

convert: fix Nemotron-H LoRA GGUF conversion#27356
CISC merged 3 commits into
ggml-org:masterfrom
frozenblade1224:nemotron-lora-conversion-fix

Conversation

@frozenblade1224

@frozenblade1224 frozenblade1224 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Overview

LoRA adapters cannot be converted to GGUF for Nemotron-H models. convert_lora_to_gguf.py fails with two one independent, sequential defects.

Defect 1 - hparams resolution (Resolved in #27101 )

Defect 2 - After working around Defect 1, the first adapter tensor is rejected. PEFT names adapter tensors from the runtime module tree (model.layers.*), while gguf-py/gguf/tensor_mapping.py registers only the on-disk checkpoint form (backbone.layers.*) for Nemotron-H. The two naming domains never meet.

  File "C:\---------\llama.cpp\conversion\base.py", line 617, in map_tensor_name
    raise ValueError(f"Can not map tensor {name!r}")
ValueError: Can not map tensor 'model.layers.12.mixer.k_proj.weight'

Fix 2 - We rename model.layers.* to backbone.layers.* for tensors containing .mixer. before delegating to the parent filter.

Additional information

Defect 2 cannot be reached without Defect 1's resolution.

The test command used for all cases is -

py .\convert_lora_to_gguf.py    --base ..\NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16   --outtype f16   --outfile ..\adapter.gguf   "C:\---------\adapters\lora_r8_re_zeros"

The used LORA adaptor is available here. After applying the 2 fixes identified above, we can get the following successful result -

INFO:lora-to-gguf:Model successfully exported to ..\adapter.gguf

Requirements

@CISC

CISC commented Aug 19, 2026

Copy link
Copy Markdown
Member

Point 1 should be fixed by #27101, point 2 is a bit mysterious, why do the naming differ?

@frozenblade1224

Copy link
Copy Markdown
Contributor Author

Indeed, #27101 settles point 1.

As for point 2, the model.\* in the tensor naming arises from NemotronHForCausalLM.__init__ in this repo. PEFT finds LoRA targets by looking through the live PyTorch module hierarchy, which consequently emits model.layers.12.mixer.k_proj.weight.

The found name disagrees with the backbone.layers.12.mixer.k_proj.weight mapped in gguf-py/gguf/tensor_mapping.py (and the actual namespace in the base checkpoint). This mismatch causes the error.

@frozenblade1224

Copy link
Copy Markdown
Contributor Author

@CISC I have removed the changes I made for Defect 1. The push now solely handles Defect 2.

@CISC
CISC requested a review from danbev August 24, 2026 06:39
@CISC
CISC merged commit bcb6084 into ggml-org:master Aug 27, 2026
1 check passed
ppenatra pushed a commit to ppenatra/llama.cpp that referenced this pull request Aug 27, 2026
* convert: fix Nemotron-H LoRA GGUF conversion

* Removed redundant JSON import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants