Model: add Tencent Hy 4 (hy_v4) preview architecture support - #28127
Open
Little0o0 wants to merge 1 commit into
Open
Model: add Tencent Hy 4 (hy_v4) preview architecture support#28127Little0o0 wants to merge 1 commit into
Little0o0 wants to merge 1 commit into
Conversation
Adds support for the Tencent Hy 4 model (Hugging Face architecture HYV4ForCausalLM, GGUF arch hy_v4): Add HF -> GGUF conversion script (conversion/hy_v4.py) and wire it into the conversion registry Register hy_v4 GGUF constants, arch enum, and writer support Implement the hy-v4 model graph, hparams, vocab and context changes Register the new arch in llama-arch and models registry Extend arch tests to cover hy_v4 Assisted by Claude Opus 5
Little0o0
requested review from
CISC,
JohannesGaessler and
ggerganov
as code owners
August 31, 2026 22:13
This comment was marked as off-topic.
This comment was marked as off-topic.
| {"name": "minerva-7b", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/sapienzanlp/Minerva-7B-base-v1.0", "chkhsh": "1431a23e583c97432bc230bff598d103ddb5a1f89960c8f1d1051aaa944d0b35"}, | ||
| {"name": "hunyuan", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/tencent/Hunyuan-A13B-Instruct", "chkhsh": "7e57df22b1fe23a7b1e1c7f3dc4e3f96d43a4eb0836d0c6bdc3436d7b2f1c664"}, | ||
| {"name": "hunyuan-dense", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/tencent/Hunyuan-4B-Instruct", "chkhsh": "bba3b3366b646dbdded5dbc42d59598b849371afc42f7beafa914afaa5b70aa6"}, | ||
| {"name": "hy_v4", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/AngelSlim/Hy4-preview-GGUF", "chkhsh": "e6ddf9c6686791c12d698d34c31ab9be1fea9af5a3d9a6909783ab382198ae1c"}, |
Contributor
There was a problem hiding this comment.
Links here should point to the model main HF repo.
Suggested change
| {"name": "hy_v4", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/AngelSlim/Hy4-preview-GGUF", "chkhsh": "e6ddf9c6686791c12d698d34c31ab9be1fea9af5a3d9a6909783ab382198ae1c"}, | |
| {"name": "hy_v4", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/tencent/Hy4-preview", "chkhsh": "e6ddf9c6686791c12d698d34c31ab9be1fea9af5a3d9a6909783ab382198ae1c"}, |
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.
Overview
Adds support for the Tencent Hy 4 model (Hugging Face architecture HYV4ForCausalLM, GGUF arch hy_v4)
This PR adds architecture support for the Tencent Hy4 preview model (Hugging Face architecture
HYV4ForCausalLM, GGUF archhy_v4). The model is published at https://huggingface.co/tencent/Hy4-preview. Some GGUF files with patches were published on https://huggingface.co/AngelSlim/Hy4-preview-GGUF , receiving 80K+ downloads in 2 days.This PR is developed from official patch and referring branch by @fairydreaming .
Hy 4 is a DeepSeek-V3-style MLA + MoE model with several notable extensions that this implementation supports:
hc_multparallel residual streams mixed per-layer viahc_attn_fn/hc_ffn_fn(pre/post) and a globalhc_head_fnbefore the final norm. The HC pre/post reduce runs in fp32 to match the reference's numerical behaviour over the full stack of layers.self_attn.linear_gate) is applied to the decompressed attention output, beforeo_proj.learnable_sink_parampassed into the attention sink term.Changes by area:
src/models/hy-v4.cppllama_model_hy_v4with iHC, gated MLA, learnable sink, MoE, optional DSA indexersrc/llama-arch.cpp,src/llama-arch.h,src/llama-model.cpp,src/models/models.hLLM_ARCH_HY_V4src/llama-hparams.h,src/llama-context.cpp,src/llama-graph.cppsrc/llama-vocab.cpp,src/llama-vocab.hLLAMA_VOCAB_PRE_TYPE_HY_V4tokenizer pre-typesrc/llama-model-saver.cppgguf-py/gguf/constants.py,gguf-py/gguf/gguf_writer.pyMODEL_ARCH.HY_V4, tensor names, metadata keysconversion/hy_v4.py,conversion/__init__.py,conversion/base.pyHYV4Model(extendsDeepseekV2Model), registered forHYV4ForCausalLMconvert_hf_to_gguf_update.pyhy_v4entry (BPE tokenizer,tencent/Hy4-preview)tests/test-llama-archs.cppAdditional information
Testing
python convert_hf_to_gguf.py <Hy4 checkpoint> --outfile hy4.ggufconverts cleanly./tests/test-llama-archspasses for the newhy_v4entryNot supported / intentionally dropped
num_nextn_predict_layers(themodel.mtp_layers.*weights) are dropped.Requirements