Text Generation
MLX
Safetensors
Transformers
kimi_k25
feature-extraction
conversational
custom_code
4-bit precision
Instructions to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 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("mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8") 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) - Transformers
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", trust_remote_code=True) model = AutoModel.from_pretrained("mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8
- SGLang
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Pi
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8"
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": "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with Docker Model Runner:
docker model run hf.co/mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8
- Hermes Agent
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 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 "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8"
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 mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8"
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 "mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8" \ --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"
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,86 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
| 3 |
library_name: mlx
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
- mlx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: modified-mit
|
| 4 |
library_name: mlx
|
|
|
|
| 5 |
tags:
|
| 6 |
- mlx
|
| 7 |
+
- transformers
|
| 8 |
+
pipeline_tag: text-generation
|
| 9 |
+
base_model: moonshotai/Kimi-K2.6
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8
|
| 13 |
+
|
| 14 |
+
This model [mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8](https://huggingface.co/mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8) was converted to MLX format from [moonshotai/Kimi-K2.6](https://huggingface.co/moonshotai/Kimi-K2.6)
|
| 15 |
+
using mlx-lm version **0.31.2**.
|
| 16 |
+
|
| 17 |
+
After the success of [the first Kimi "DQ3_K_M" model](https://huggingface.co/mlx-community/Kimi-K2-Instruct-0905-mlx-DQ3_K_M) and the K2.5, this is a new update for Kimi-K2.6!
|
| 18 |
+
|
| 19 |
+
This is created for people using a single Apple Mac Studio M3 Ultra with 512 GB. The 4-bit version of Kimi K2 does not fit. Using research results, we aim to get 4-bit performance from a slightly smaller and smarter quantization. It should also not be so large that it leaves no memory for a useful context window.
|
| 20 |
+
|
| 21 |
+
You can find more similar MLX model quants for Apple Mac Studio with 512 GB at https://huggingface.co/bibproj
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
pip install mlx-lm
|
| 25 |
+
|
| 26 |
+
mlx_lm.generate --model mlx-community/Kimi-K2.6-mlx-DQ3_K_M-q8--temp 0.6 --min-p 0.01 --max-tokens 4096 --trust-remote-code --prompt "Hallo"
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## What is this DQ3_K_M?
|
| 32 |
+
|
| 33 |
+
In the Arxiv paper [Quantitative Analysis of Performance Drop in DeepSeek Model Quantization](https://arxiv.org/abs/2505.02390) the authors write,
|
| 34 |
+
|
| 35 |
+
> We further propose `DQ3_K_M`, a dynamic 3-bit quantization method that significantly outperforms traditional `Q3_K_M` variant on various benchmarks, which is also comparable with 4-bit quantization (`Q4_K_M`) approach in most tasks.
|
| 36 |
+
|
| 37 |
+
and
|
| 38 |
+
|
| 39 |
+
> dynamic 3-bit quantization method (`DQ3_K_M`) that outperforms the 3-bit quantization implementation in `llama.cpp` and achieves performance comparable to 4-bit quantization across multiple benchmarks.
|
| 40 |
+
|
| 41 |
+
The resulting multi-bitwidth quantization has been well tested and documented.
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## How can you create your own DQ3_K_M quants?
|
| 46 |
+
|
| 47 |
+
The recipe is the same as that for the K2.5 model. Both are a bit different from that of [the first Kimi "DQ3_K_M" model](https://huggingface.co/mlx-community/Kimi-K2-Instruct-0905-mlx-DQ3_K_M), which was described there. To make to the quant perform better under stress, only the expert tensors are quantized to a mix of 3-bit and 4-bit. All the other tensors are kept at 8-bit. You could say that this quant has an 8-bit "brain" and 3-bit/4-bit experts. The sizes of all three these quants are roughly the same. The 8-bit routing does reduce the tokens/second by a few %. You get a slightly slower TG, but better quality results.
|
| 48 |
+
|
| 49 |
+
In the `convert.py` file of mlx-lm on your system ( [you can see the original code here](https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/convert.py) ), replace the code inside `def mixed_quant_predicate()` with something like
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
index = (
|
| 53 |
+
int(path.split(".")[layer_location])
|
| 54 |
+
if len(path.split(".")) > layer_location
|
| 55 |
+
else 0
|
| 56 |
+
)
|
| 57 |
+
# Build a mixed quant like "DQ3" similar to the "DQ3" of Arxiv paper https://arxiv.org/abs/2505.02390
|
| 58 |
+
# Quantitative Analysis of Performance Drop in DeepSeek Model Quantization
|
| 59 |
+
q_bits = 8
|
| 60 |
+
if "switch_mlp.up_proj" in path:
|
| 61 |
+
q_bits = 3
|
| 62 |
+
if "switch_mlp.gate_proj" in path:
|
| 63 |
+
q_bits = 3
|
| 64 |
+
if "switch_mlp.down_proj" in path:
|
| 65 |
+
q_bits = 3
|
| 66 |
+
# Layers up to 5 are higher quality
|
| 67 |
+
if index < 5:
|
| 68 |
+
q_bits = 5
|
| 69 |
+
# Every 5th layer is "medium" quality
|
| 70 |
+
if (index % 5) == 0:
|
| 71 |
+
q_bits = 4
|
| 72 |
+
print("path:", path, "index:", index, "q_bits:", q_bits)
|
| 73 |
+
return {"group_size": group_size, "bits": q_bits, "mode": mode}
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
Then create your DQ3_K_M quant with
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
mlx_lm.convert --hf-path moonshotai/Kimi-K2.6 --mlx-path your-model-DQ3_K_M -q --quant-predicate mixed_3_4 --trust-remote-code
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
**NOTE***: With Kimi-K2.5 and Kimi-K2.6 you need to first dequantize the model before you can create the MLX quant. This step requires just over 2TB of additional disk space.
|
| 83 |
+
|
| 84 |
---
|
| 85 |
+
|
| 86 |
+
Enjoy!
|