Instructions to use Xylolabs/Hy4-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Xylolabs/Hy4-MLX-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("Xylolabs/Hy4-MLX-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use Xylolabs/Hy4-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Xylolabs/Hy4-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Xylolabs/Hy4-MLX-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Xylolabs/Hy4-MLX-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Xylolabs/Hy4-MLX-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Xylolabs/Hy4-MLX-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Xylolabs/Hy4-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Xylolabs/Hy4-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "Xylolabs/Hy4-MLX-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download ORIGINS.md from Xylolabs/Hy4-MLX-4bit: direct link, hf CLI and curl.
- Browser
- Download file 5.12 kB
-
https://huggingface.co/Xylolabs/Hy4-MLX-4bit/resolve/main/ORIGINS.md
- Command line
-
hf download hf://Xylolabs/Hy4-MLX-4bit/ORIGINS.md
-
curl -L -o ORIGINS.md https://huggingface.co/Xylolabs/Hy4-MLX-4bit/resolve/main/ORIGINS.md
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_vlclass (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'shy_v4graph rotates consecutive pairs on unpermuted rope rows. Thehy_v4text class at the pinned commit still rotates split halves. - Latent norm epsilon.
q_a_layernormandkv_a_layernormuserms_norm_eps(1e-5), ashy_v4_vland llama.cpp do. Thehy_v4class uses 1e-6. Setmla_norm_epsin the config to override. - LM head. Stored in the checkpoint dtype (BF16) and multiplied in float32.
sanitizeupcasts it at load time. Set"enable_lm_head_fp32": falseto 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.pyis the text model with the image M-RoPE positions added and gives bit-identical text-only logits tohy_v4.pyin float32 on the miniature test.