You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored and
Patrick Hoffmann
committed
llama: add the glm5next NextN/MTP draft head
GLM-5.3-Flash ships a NextN block that neither upstream draft implements:
ggml-org#27752 has no MTP graph at all, ggml-org#27754 asserts "glm5next NextN graph not
implemented yet". The tensors were already declared by the loader but
carried TENSOR_SKIP unconditionally, so the head sat unused in every GGUF.
Model it on the working GLM-5.2 head in glm-dsa.cpp:
enorm(embed) + hnorm(prev_hidden) -> concat -> eh_proj -> one dense DSA
decoder block -> shared_head_norm -> shared LM head.
graph_mtp derives from graph through a no-trunk tag constructor so it calls
the trunk's own build_mla_layer and build_ffn_layer instead of duplicating
them; attention and FFN semantics therefore cannot drift from the trunk.
Two deliberate differences: no mHC mixer, because the loader creates no hc_*
tensors for the NextN block, and inp_kpool = nullptr, so build_dsa_top_k is
skipped and the block runs dense MLA — the same choice the GLM-5.2 head makes.
Loader now follows the glm-dsa pattern: trunk and NextN may live in separate
GGUFs in either direction, and TENSOR_SKIP is applied only when the loader
was not asked for MTP. load_mtp defaults to false, so ordinary loading is
byte-for-byte unchanged.
An MTP context now allocates a plain KV cache filtered to the NextN layers.
Without that it built a second full hybrid memory for the entire model, which
cannot fit at production context sizes.
NOT VALIDATED: this has never been executed. test-llama-archs covers no MTP
head for any architecture, so there is no harness to extend, and no ROCm or
GLM-5.3 checkpoint was available. Acceptance rate and correctness must be
measured on hardware before relying on it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments