A GGUF MTP Extract and Merge Tool #1849
Draft
FNsi wants to merge 7 commits into
Draft
Conversation
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
approved these changes
May 21, 2026
ikawrakow
left a comment
Owner
There was a problem hiding this comment.
I haven't tested this, hopefully it works and is useful to people.
Author
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...... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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