Skip to content

Refactor: convert_hf_to_gguf.py - #17114

Merged
pwilkin merged 10 commits into
ggml-org:masterfrom
pwilkin:convert_refactor
May 15, 2026
Merged

pwilkin merged 10 commits into
ggml-org:masterfrom
pwilkin:convert_refactor

Conversation

@pwilkin

@pwilkin pwilkin commented Nov 9, 2025 •

Copy link
Copy Markdown
Member

From the creators of the horror show "llama-model.cpp - refactoring" comes the sequel: "convert_hf_to_gguf.py - refactoring".

Still in draft because it's not all finished, but I thought that if someone wanted to chime in I'll put it up already.

@CISC

CISC commented Nov 9, 2025

Copy link
Copy Markdown
Member

🤯 Looks like a decent enough plan though. Only downside is that there will no longer just be a single script to grab and run, but that has been a source of error and confusion anyway.

You should derive _MODEL_MODULES from models_map.

@CISC

CISC commented Nov 9, 2025

Copy link
Copy Markdown
Member

@compilade Your input would be much appreciated as well.

@CISC CISC added the refactoring Refactoring label Nov 9, 2025
Comment thread conversion/__init__.py Resolved
@compilade

Copy link
Copy Markdown
Collaborator

(note for later) This will (trivially) conflict with at least

@CISC

CISC commented Nov 9, 2025 •

Copy link
Copy Markdown
Member

Are you expecting more work on these? Can be merged now.

@pwilkin

pwilkin commented Nov 12, 2025

Copy link
Copy Markdown
Member Author

Okay, so I've actually gone over and verified the conversion results - refactored, applied some tips from here while doing that and most of all - tested that it actually works.

@pwilkin

pwilkin commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

Conversion verification script: https://gist.github.com/pwilkin/1e488423e9f2549c0518179bb9f752d5

@pwilkin
pwilkin marked this pull request as ready for review November 18, 2025 16:06
@pwilkin
pwilkin requested a review from CISC as a code owner November 18, 2025 16:06
@pwilkin

pwilkin commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

@CISC have fun! :)

@CISC

CISC commented Nov 18, 2025

Copy link
Copy Markdown
Member

@CISC have fun! :)

You need to fix the CIs first, esp. convert_hf_to_gguf_update.py. :)

@pwilkin

pwilkin commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

Yeah, might've went out of draft too early :>

@pwilkin

pwilkin commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

@ngxson shamed me by finishing the model code refactor, so I decided to come back to this oldie-but-goodie.

@CISC something for ya :)

@pwilkin

pwilkin commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

P.S. The analyze_conversion_faithfulness.py script is of course temporary.

@pwilkin
pwilkin marked this pull request as ready for review April 18, 2026 20:16
Comment thread conversion/__init__.py Resolved
Comment thread convert_hf_to_gguf.py Resolved
Comment thread convert_lora_to_gguf.py Resolved
@CISC

CISC commented Apr 27, 2026

Copy link
Copy Markdown
Member

@pwilkin Mind focusing a little bit on this one this week so we can bring it to completion?

@pwilkin

pwilkin commented Apr 27, 2026

Copy link
Copy Markdown
Member Author

@CISC yup, will take a look tomorrow or Wed probably (unless I'm still alive in the evening, then maybe today).

@pwilkin
pwilkin force-pushed the convert_refactor branch from b8d67c3 to a1d470b Compare May 1, 2026 15:56
@pwilkin

pwilkin commented May 1, 2026

Copy link
Copy Markdown
Member Author

@CISC alrighy, should be good to go.

@CISC

CISC commented May 1, 2026

Copy link
Copy Markdown
Member

I'd like to merge #22597 first

@CISC

CISC commented May 13, 2026

Copy link
Copy Markdown
Member

@pwilkin Sigh, sorry for the delay yet again, it has been hectic lately, but given it will be a long weekend starting tomorrow I'm hoping we can wrap this up this week if you have the time.

@pwilkin

pwilkin commented May 13, 2026

Copy link
Copy Markdown
Member Author

Aight, let me rebase again.

@pwilkin
pwilkin merged commit cc7200b into ggml-org:master May 15, 2026
7 checks passed
mzyil added a commit to mzyil/llama.cpp that referenced this pull request May 16, 2026
Resolved conflict in convert_hf_to_gguf.py: upstream refactored the
monolithic script into conversion/* modules (ggml-org#17114). Ported the MTP
PR's _Qwen35MtpMixin and --mtp / --no-mtp CLI flags into the new
conversion/qwen.py and entry script.
@fluffle

fluffle commented May 19, 2026

Copy link
Copy Markdown

Slightly suspicious that you need to include the "conversion" dir in all the docker images now? At least, the latest docker images can't run convert_hf_to_gguf.py any longer because of ModuleNotFoundError: No module named 'conversion'...

@CISC

CISC commented May 19, 2026

Copy link
Copy Markdown
Member

Slightly suspicious that you need to include the "conversion" dir in all the docker images now? At least, the latest docker images can't run convert_hf_to_gguf.py any longer because of ModuleNotFoundError: No module named 'conversion'...

Forgot that was a thing, will fix.

jimbothigpen pushed a commit to jimbothigpen/af-engn that referenced this pull request May 21, 2026
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
jimbothigpen pushed a commit to jimbothigpen/af-engn that referenced this pull request May 21, 2026
The three files touched by mainline 9f5f0e6 are all already at the
target state in ygg HEAD:

  - convert_hf_to_gguf.py: ygg uses the per-arch refactor (Bundle C
    ggml-org#17114); Gemma4Model lives in conversion/gemma.py. mainline ggml-org#17114
    was merged AFTER ggml-org#22804 in upstream, so the refactor carried the
    NVFP4 _generate_nvfp4_tensors method and updated filter_tensors
    along with it. conversion/gemma.py lines 719-752 already contain
    the upstream additions verbatim.
  - gguf-py/gguf/constants.py: MODEL_ARCH.GEMMA4 block (line 2522+)
    already includes FFN_GATE_EXP and FFN_UP_EXP (auto-merged cleanly).
  - src/models/gemma4.cpp: ffn_gate_up_exps TENSOR_NOT_REQUIRED path
    and build_moe_ffn argument updates already in HEAD (auto-merged
    cleanly).

Empty commit retained for audit-trail/lineage; pairs with the previous
loader port (baddad949 = mainline 42928bc).
baramofme pushed a commit to baramofme/llama-cpp-turboquant that referenced this pull request May 23, 2026
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
jimbothigpen pushed a commit to jimbothigpen/af-engn that referenced this pull request May 25, 2026
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
jimbothigpen pushed a commit to jimbothigpen/af-engn that referenced this pull request May 25, 2026
The three files touched by mainline 9f5f0e6 are all already at the
target state in ygg HEAD:

  - convert_hf_to_gguf.py: ygg uses the per-arch refactor (Bundle C
    ggml-org#17114); Gemma4Model lives in conversion/gemma.py. mainline ggml-org#17114
    was merged AFTER ggml-org#22804 in upstream, so the refactor carried the
    NVFP4 _generate_nvfp4_tensors method and updated filter_tensors
    along with it. conversion/gemma.py lines 719-752 already contain
    the upstream additions verbatim.
  - gguf-py/gguf/constants.py: MODEL_ARCH.GEMMA4 block (line 2522+)
    already includes FFN_GATE_EXP and FFN_UP_EXP (auto-merged cleanly).
  - src/models/gemma4.cpp: ffn_gate_up_exps TENSOR_NOT_REQUIRED path
    and build_moe_ffn argument updates already in HEAD (auto-merged
    cleanly).

Empty commit retained for audit-trail/lineage; pairs with the previous
loader port (baddad949 = mainline 42928bc).
elementalcollision added a commit to elementalcollision/safetensorstogguf that referenced this pull request Jun 29, 2026
…r) (#7)

llama.cpp PR ggml-org/llama.cpp#17114 (merged 2026-05-15, commit cc7200bf)
renamed the converter base class `Model` -> `ModelBase` and a later change split
it into a `conversion` package, so `Model = convert_module.Model` died with
`module 'convert_hf_to_gguf' has no attribute 'Model'` (issue #6).

Resolve the base class as `Model` OR `ModelBase` (plus `LlamaModel`), so current
llama.cpp works out of the box. If neither base class is present, fail with a
clear, actionable message — the converter API changed again — instead of a
cryptic AttributeError, and propagate it without re-wrapping. README gains an
"llama.cpp compatibility" note with the known-good pre-#17114 fallback.

Fixes #6.

🤖 Generated autonomously by Chimera — https://github.com/elementalcollision/codex-chimaera
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python python script changes refactoring Refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants