Skip to content

A GGUF MTP Extract and Merge Tool #1849

Draft
FNsi wants to merge 7 commits into
ikawrakow:mainfrom
FNsi:Pyscript-mtp
Draft

A GGUF MTP Extract and Merge Tool #1849
FNsi wants to merge 7 commits into
ikawrakow:mainfrom
FNsi:Pyscript-mtp

Conversation

@FNsi

@FNsi FNsi commented May 20, 2026

Copy link
Copy Markdown

GGUF MTP (Multi-Token Prediction) Extract and Merge Tool
Extract NextN/MTP layers from a model that has them and insert to model without them, use for add mtp layer to unsloth finetuned model or existed gguf without mtp layer. Should work with Qwen3.6-27B, didn't test anything else..
Usage:
Extract MTP from source model and merge into target model
python gguf_mtp_extract_merge.py extract-merge
~/source-with-mtp.gguf
~/target-without-mtp.gguf
~/output-with-mtp.gguf
Just extract MTP tensors to a standalone file
python gguf_mtp_extract_merge.py extract
~/source-with-mtp.gguf
~/mtp-layers.gguf
Just merge extracted MTP tensors into target
python gguf_mtp_extract_merge.py merge
~/mtp-layers.gguf
~/target-without-mtp.gguf
~/output-with-mtp.gguf

AI usage: mostly generate by Kimi k2.6

FNsi added 7 commits May 6, 2026 17:12
Nowadays unsloth trained Qwen models are not containing mtp, this script extract MTP layers from a model that has them, and merge them into
a finetune or whatever model that doesn't have them.

Ai usage: wrote with  kimi k2.6 base on gguf editor.

Usage:
    # Extract MTP from source model and merge into target model
    python gguf_mtp_extract_merge.py extract-merge \
        ~/source-with-mtp.gguf \
        ~/target-without-mtp.gguf \
        ~/output-with-mtp.gguf

    # Just extract MTP tensors to a standalone file
    python gguf_mtp_extract_merge.py extract \
        ~/source-with-mtp.gguf \
        ~/mtp-layers.gguf

    # Just merge extracted MTP tensors into target
    python gguf_mtp_extract_merge.py merge \
        ~/mtp-layers.gguf \
        ~/target-without-mtp.gguf \
        ~/output-with-mtp.gguf
now keep most origin gguf metadata.

@ikawrakow ikawrakow left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this, hopefully it works and is useful to people.

@FNsi

FNsi commented May 21, 2026

Copy link
Copy Markdown
Author

I haven't tested this, hopefully it works and is useful to people.

Thanks for that, I also only tested the 27b version since I do only have one 27B mtp and one GRM (finetuned model without mtp. (Edit: after merge it) Accept rate with draft-max 4 works fine just like origin);

But maybe better keep it as draft? Simply think users here can use it even it's a draft, also because...I guess this tool is not needed anymore in very short future, like weeks......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants