LLM inference in C/C++
C++ ggml
convert_hf_to_gguf: support split MTP export for HY V3 (#25641)
Thiago Padilhacb489bc0fb78
diff --git a/conversion/base.py b/conversion/base.pyindex 0421aa4bc4..1b85ef0a1b 100644--- a/conversion/base.py+++ b/conversion/base.py@@ -109,7 +109,9 @@ class ModelBase:sentence_transformers_dense_modules: bool = False# MTP (multi-token prediction) export modes; set by main() before instantiation.- # Architectures opt in by overriding the handling (see _Qwen35MtpMixin).+ # Architectures that implement the filtering/export behavior opt in by+ # setting supports_mtp_export = True on their model class or a mixin.+ supports_mtp_export: bool = Falsemtp_only: bool = Falseno_mtp: bool = Falsediff --git a/conversion/hunyuan.py b/conversion/hunyuan.pyindex 4d2545f8b4..65d294fbe9 100644--- a/conversion/hunyuan.py+++ b/conversion/hunyuan.py@@ -361,6 +361,7 @@ class HunyuanVLTextModel(HunYuanModel):@ModelBase.register("HYV3ForCausalLM")class HYV3Model(TextModel):model_arch = gguf.MODEL_ARCH.HY_V3+ supports_mtp_export = True# Trunk layer count, stashed before indexing so the classmethod# filter_tensors can identify the appended MTP block(s) (mirrorsdiff --git a/conversion/qwen.py b/conversion/qwen.pyindex 0356bd2da7..82d42fcc16 100644--- a/conversion/qwen.py+++ b/conversion/qwen.py@@ -541,6 +541,7 @@ class _Qwen35MtpMixin:`mtp.*` to the standard layer-indexed nextn naming so the existingtensor_map handles them."""+ supports_mtp_export = Truehparams: dict[str, Any]model_arch: gguf.MODEL_ARCHgguf_writer: gguf.GGUFWriterdiff --git a/conversion/step3.py b/conversion/step3.pyindex 49bb5244a6..f7cdc997e5 100644--- a/conversion/step3.py+++ b/conversion/step3.py@@ -98,6 +98,7 @@ class Step3VLTextModel(Qwen3Model):@ModelBase.register("Step3p5ForCausalLM", "Step3p7ForConditionalGeneration")class Step35Model(TextModel):model_arch = gguf.MODEL_ARCH.STEP35+ supports_mtp_export = True# The --mtp / --no-mtp toggles are ModelBase.mtp_only / no_mtp (set in# convert_hf_to_gguf.py main()). Unlike Qwen3.5, which stores MTP under adiff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.pyindex 3b23d5ebc0..2c5e62a16f 100755--- a/convert_hf_to_gguf.py+++ b/convert_hf_to_gguf.py@@ -259,10 +259,8 @@ def main() -> None:sys.exit(1)if args.mtp or args.no_mtp:- from conversion.qwen import _Qwen35MtpMixin- from conversion.step3 import Step35Model- if not (issubclass(model_class, _Qwen35MtpMixin) or issubclass(model_class, Step35Model)):- logger.error("--mtp / --no-mtp are only supported for Qwen3.5/3.6 and Step3.5 text variants today")+ if not model_class.supports_mtp_export:+ logger.error("--mtp / --no-mtp are not supported for %s", model_architecture)sys.exit(1)if args.no_mtp:model_class.no_mtp = True