]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
convert_hf_to_gguf: support split MTP export for HY V3 (#25641)
authorThiago Padilha <redacted>
Tue, 14 Jul 2026 09:43:15 +0000 (06:43 -0300)
committerGitHub <redacted>
Tue, 14 Jul 2026 09:43:15 +0000 (11:43 +0200)
- Add a supports_mtp_export capability to ModelBase so architectures can opt
  into --mtp and --no-mtp without extending a central class allowlist.
- Enable the capability for the existing Qwen3.5/3.6 and Step3.5/3.7
  implementations, and for HY V3, whose converter already supports
  filtering the appended MTP layers.

conversion/base.py
conversion/hunyuan.py
conversion/qwen.py
conversion/step3.py
convert_hf_to_gguf.py

index 0421aa4bc4d3a8c97ebeaf8812d99f4865161cbd..1b85ef0a1b899cb571a6b05290a291f30a84c8f8 100644 (file)
@@ -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 = False
     mtp_only: bool = False
     no_mtp: bool = False
 
index 4d2545f8b47353cfb18f932cc3de0beb0144d004..65d294fbe978059f0ee47a860858cc7b04493d3d 100644 (file)
@@ -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) (mirrors
index 0356bd2da7831b5f35f31281e3061d015cd7f2d2..82d42fcc1674968c8fb3a03d8b9a4702ae7474e7 100644 (file)
@@ -541,6 +541,7 @@ class _Qwen35MtpMixin:
     `mtp.*` to the standard layer-indexed nextn naming so the existing
     tensor_map handles them."""
 
+    supports_mtp_export = True
     hparams: dict[str, Any]
     model_arch: gguf.MODEL_ARCH
     gguf_writer: gguf.GGUFWriter
index 49bb5244a62b3b78f077694df2360a54330ed085..f7cdc997e5286d62619cd95798d344f6c535800f 100644 (file)
@@ -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 a
index 3b23d5ebc0d303f4b5280d18207b642f7b4b4bab..2c5e62a16fbef67ef1bba243df7e3aa7b4de1543 100755 (executable)
@@ -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