# Origins `hy_v4.py` is an MLX port of the Hy4 text decoder for mlx-lm. `convert_hy4.py` streams the published BF16 checkpoint into an mlx-lm folder that loads it. | File | Source | License | | --- | --- | --- | | `hy_v4.py`, model equations | Hugging Face Transformers, `src/transformers/models/hy_v4/` and `hy_v4_vl/` at commit `439bba079891ecd766900e8ce80ee961b94ef132`. Copyright 2026 Tencent HunYuan Team and The HuggingFace Inc. team | Apache-2.0 | | `hy_v4.py`, MLA attention layout, indexer skeleton, cache layout | mlx-lm 0.32.2, `mlx_lm/models/deepseek_v32.py`. Copyright 2025 Apple Inc. | MIT | | `hy_v4.py` hyper-connection, sink and gate code; `convert_hy4.py` | Our own, adapted from our earlier Hy4-flash MLX port | Same terms as the release | | `hy_v4_vl.py` | `hy_v4.py` with the image M-RoPE positions added: Hugging Face Transformers `src/transformers/models/hy_v4/` and `hy_v4_vl/` at commit `439bba079891ecd766900e8ce80ee961b94ef132` (Copyright 2026 Tencent HunYuan Team and The HuggingFace Inc. team); MLA layout and cache from mlx-lm 0.32.2 `deepseek_v32.py` (Copyright 2025 Apple Inc.) | Apache-2.0 (`LICENSE.transformers`); MIT (`LICENSE.mlx-lm`) | | `vision_v4.py` | Transformers `hy_v4_vl` vision tower, commit `439bba079891ecd766900e8ce80ee961b94ef132`, adapted from our Hy4-flash MLX vision code | Apache-2.0 (`LICENSE.transformers`) | | `processing_v4.py` | Transformers `HYV4VLImageProcessor` and `HYV4VLProcessor`, commit `439bba079891ecd766900e8ce80ee961b94ef132` | Apache-2.0 (`LICENSE.transformers`) | | `dfly_v4.py` | Our Hy4-flash MLX drafter, following vLLM `models/hy_v4` (Tencent and vLLM contributors) at `jeejeelee/vllm@8cbb80efa3974d10bb09c87580627bd874a3606b`; MLA pieces from mlx-lm 0.32.2 | Apache-2.0 (vLLM); MIT (`LICENSE.mlx-lm`) | | `speculative_v4.py` | Our Hy4-flash speculative decoder, following vLLM `dfly_inputs.py` and `dfly_speculator.py` at `jeejeelee/vllm@8cbb80efa3974d10bb09c87580627bd874a3606b`; generation types from mlx-lm 0.32.2 | Apache-2.0 (vLLM); MIT (`LICENSE.mlx-lm`) | | `vision/vision.safetensors` | `tencent/Hy4` at revision `c10c0de5b6f850703fb0a90e65d1c32b558b9167` (the `vit.*` tensors of eight shards), converted to bf16 with the three convolution kernels transposed | Tencent Hy License, Version 1.0 (`LICENSE`) | | `dfly/dfly.safetensors` | `tencent/Hy4` at revision `c10c0de5b6f850703fb0a90e65d1c32b558b9167`, shard 245 (sha256 `01ea25e7ca48db231bd04f26fed23b3909e7730fd2e8c15b6eba8b1f75f64c8b`), converted to bf16 | Tencent Hy License, Version 1.0 (`LICENSE`) | The Apache-2.0 text ships as `LICENSE.transformers`. The mlx-lm MIT notice: "Copyright © 2023 Apple Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." ## Behavior choices - **RoPE layout.** Adjacent-pair (interleaved) rotation for both the MLA attention and the indexer. The released checkpoint needs it: Transformers' `hy_v4_vl` class (the checkpoint's own architecture) rotates adjacent pairs, the maintainers confirmed it on Transformers PR 50589 ("fix(hy_v4): use interleaved RoPE to match checkpoint layout"), and llama.cpp's `hy_v4` graph rotates consecutive pairs on unpermuted rope rows. The `hy_v4` text class at the pinned commit still rotates split halves. - **Latent norm epsilon.** `q_a_layernorm` and `kv_a_layernorm` use `rms_norm_eps` (1e-5), as `hy_v4_vl` and llama.cpp do. The `hy_v4` class uses 1e-6. Set `mla_norm_eps` in the config to override. - **LM head.** Stored in the checkpoint dtype (BF16) and multiplied in float32. `sanitize` upcasts it at load time. Set `"enable_lm_head_fp32": false` to multiply in BF16. - **Attention sinks.** The fused attention kernel takes sinks in the activation dtype, so BF16 models round the sink logits to BF16. The reference keeps them in float32. - **Not implemented.** Batched generation with padding and quantized KV caches. Vision input (`hy_v4_vl.py`, `vision_v4.py`, `processing_v4.py`) and the DFly2 drafter (`dfly_v4.py`, `speculative_v4.py`) are separate modules; `hy_v4_vl.py` is the text model with the image M-RoPE positions added and gives bit-identical text-only logits to `hy_v4.py` in float32 on the miniature test.