mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-07-21 02:05:51 +00:00
convert_hf_to_gguf: support split MTP export for HY V3 (#25641)
- 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.
This commit is contained in:
+3
-1
@@ -109,7 +109,9 @@ class ModelBase:
|
|||||||
sentence_transformers_dense_modules: bool = False
|
sentence_transformers_dense_modules: bool = False
|
||||||
|
|
||||||
# MTP (multi-token prediction) export modes; set by main() before instantiation.
|
# 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
|
mtp_only: bool = False
|
||||||
no_mtp: bool = False
|
no_mtp: bool = False
|
||||||
|
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ class HunyuanVLTextModel(HunYuanModel):
|
|||||||
@ModelBase.register("HYV3ForCausalLM")
|
@ModelBase.register("HYV3ForCausalLM")
|
||||||
class HYV3Model(TextModel):
|
class HYV3Model(TextModel):
|
||||||
model_arch = gguf.MODEL_ARCH.HY_V3
|
model_arch = gguf.MODEL_ARCH.HY_V3
|
||||||
|
supports_mtp_export = True
|
||||||
|
|
||||||
# Trunk layer count, stashed before indexing so the classmethod
|
# Trunk layer count, stashed before indexing so the classmethod
|
||||||
# filter_tensors can identify the appended MTP block(s) (mirrors
|
# filter_tensors can identify the appended MTP block(s) (mirrors
|
||||||
|
|||||||
@@ -541,6 +541,7 @@ class _Qwen35MtpMixin:
|
|||||||
`mtp.*` to the standard layer-indexed nextn naming so the existing
|
`mtp.*` to the standard layer-indexed nextn naming so the existing
|
||||||
tensor_map handles them."""
|
tensor_map handles them."""
|
||||||
|
|
||||||
|
supports_mtp_export = True
|
||||||
hparams: dict[str, Any]
|
hparams: dict[str, Any]
|
||||||
model_arch: gguf.MODEL_ARCH
|
model_arch: gguf.MODEL_ARCH
|
||||||
gguf_writer: gguf.GGUFWriter
|
gguf_writer: gguf.GGUFWriter
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ class Step3VLTextModel(Qwen3Model):
|
|||||||
@ModelBase.register("Step3p5ForCausalLM", "Step3p7ForConditionalGeneration")
|
@ModelBase.register("Step3p5ForCausalLM", "Step3p7ForConditionalGeneration")
|
||||||
class Step35Model(TextModel):
|
class Step35Model(TextModel):
|
||||||
model_arch = gguf.MODEL_ARCH.STEP35
|
model_arch = gguf.MODEL_ARCH.STEP35
|
||||||
|
supports_mtp_export = True
|
||||||
|
|
||||||
# The --mtp / --no-mtp toggles are ModelBase.mtp_only / no_mtp (set in
|
# 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
|
# convert_hf_to_gguf.py main()). Unlike Qwen3.5, which stores MTP under a
|
||||||
|
|||||||
@@ -259,10 +259,8 @@ def main() -> None:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if args.mtp or args.no_mtp:
|
if args.mtp or args.no_mtp:
|
||||||
from conversion.qwen import _Qwen35MtpMixin
|
if not model_class.supports_mtp_export:
|
||||||
from conversion.step3 import Step35Model
|
logger.error("--mtp / --no-mtp are not supported for %s", model_architecture)
|
||||||
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")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if args.no_mtp:
|
if args.no_mtp:
|
||||||
model_class.no_mtp = True
|
model_class.no_mtp = True
|
||||||
|
|||||||
Reference in New Issue
Block a user