8-bit MLX quantization of IFM/K2-Horizon-7B, converted from revision f846b1e. 8.5 bits/weight effective, 9.6 GB on disk. For Apple silicon.
K2-Horizon-7B is IFM's medium dense K2-Horizon model: a 7B decoder-only model with a 512K (524,288-token) context window.
mlx-lm doesn't support the k2_horizon architecture yet. There's an open request: mlx-lm#1876. Until support lands, this repo ships the MLX model code (k2_horizon.py), which mlx-lm loads through the model_file entry in config.json. So the released mlx-lm works as-is:
pip install -U mlx-lmPass --trust-remote-code (or trust_remote_code=True). mlx-lm 0.31.3 loads the file without it, but newer versions require it. The file runs on your machine, so read it first if you like; its comments describe how it differs from IFM's PyTorch code.
Once K2-Horizon support lands in a released mlx-lm, this repo will be updated to use it. If something breaks after that, open a discussion here asking for a re-upload.
mlx_lm.convert -q --q-bits 8 --q-group-size 64 (integer affine quantization, bf16 scales and biases). All linear layers and the embeddings are 8-bit. WikiText-2 perplexity is within +0.2% of bf16, so it is effectively lossless.
Peak 9.7 GB for a short prompt; fits a 24 GB Mac. The KV cache adds about 144 KB per token in bf16 (18.0 GB at 128K tokens), so long contexts need more memory; --max-kv-size and KV-cache quantization (--kv-bits 8, where available) reduce it.
The MLX implementation was checked against IFM's PyTorch code (modeling_k2_horizon.py) in fp32 on the real weights of this model:
Smoke-tested after conversion with released mlx-lm 0.31.3: 17 * 23 → 391 and "capital of Australia" → Canberra, both ending normally. On a Mac Studio M4 Max 128GB: 52.5 tok/s generation, peak 9.7 GB (short prompt).
WikiText-2 test perplexity (128 × 512 tokens, lower is better) and generation speed on an M4 Max 128GB, all measured the same way:
| bf16 | 8-bit | 4-bit | |
|---|---|---|---|
| Bits/weight | 16 | 8.5 | 6.4 |
| Disk | 18.0 GB | 9.6 GB | 7.2 GB |
| Peak memory | 18.1 GB | 9.7 GB | 7.3 GB |
| WikiText-2 perplexity | 14.738 | 14.762 (+0.2%) | 15.395 (+4.5%) |
| Generation | 29.3 tok/s | 52.5 tok/s | 69.0 tok/s |
Perplexity is a coarse signal. Test the versions on your own workload before picking one. Other K2-Horizon sizes: the K2-Horizon collection.
mlx_lm.generate --model mlx-community/K2-Horizon-7B-8bit --trust-remote-code --prompt "Explain mixture-of-experts in two sentences." --max-tokens 2048from mlx_lm import load, generate
# Newer mlx-lm versions need trust_remote_code=True; on mlx-lm 0.31.3 use load("mlx-community/K2-Horizon-7B-8bit").
model, tokenizer = load("mlx-community/K2-Horizon-7B-8bit", trust_remote_code=True)
messages = [{"role": "user", "content": "Explain mixture-of-experts in two sentences."}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
print(generate(model, tokenizer, prompt, max_tokens=2048))mlx_lm.chat and mlx_lm.server take the same --trust-remote-code flag.
The model thinks before it answers, inside <ifm|think> … </ifm|think>. Leave room for that in max_tokens. The effort level is set with reasoning_effort in the chat template: "high" (default), "medium" or "low", e.g. apply_chat_template(messages, add_generation_prompt=True, reasoning_effort="low").
Notes:
<ifm|think> tags yet, so mlx_lm.server returns the thinking text inside content, before </ifm|think>, rather than in a separate reasoning field. K2-Horizon's tool-call format isn't parsed yet either.Apache-2.0, inherited from the base model. Refer to the original model card for architecture, benchmarks and intended use. All credit for the model belongs to IFM.