Instructions to use samwang0041/Qwen3.6-27B-MLX-4bit-MTP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use samwang0041/Qwen3.6-27B-MLX-4bit-MTP 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("samwang0041/Qwen3.6-27B-MLX-4bit-MTP") 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 samwang0041/Qwen3.6-27B-MLX-4bit-MTP with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samwang0041/Qwen3.6-27B-MLX-4bit-MTP"
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": "samwang0041/Qwen3.6-27B-MLX-4bit-MTP" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use samwang0041/Qwen3.6-27B-MLX-4bit-MTP with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "samwang0041/Qwen3.6-27B-MLX-4bit-MTP"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "samwang0041/Qwen3.6-27B-MLX-4bit-MTP" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samwang0041/Qwen3.6-27B-MLX-4bit-MTP", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use samwang0041/Qwen3.6-27B-MLX-4bit-MTP 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 "samwang0041/Qwen3.6-27B-MLX-4bit-MTP"
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 samwang0041/Qwen3.6-27B-MLX-4bit-MTP
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use samwang0041/Qwen3.6-27B-MLX-4bit-MTP with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samwang0041/Qwen3.6-27B-MLX-4bit-MTP"
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 "samwang0041/Qwen3.6-27B-MLX-4bit-MTP" \ --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"
Qwen3.6-27B-MLX-4bit-MTP
English | ไธญๆ
Native MTP (Multi-Token Prediction) weights preserved for MLX inference. The official
mlx-communityreleases strip MTP weights duringsanitize(), breaking speculative decoding support.ๅ็ไฟ็ MTP๏ผๅค token ้ขๆต๏ผๆ้็ MLX ้ๅ็ๆฌใๅฎๆน
mlx-communityๅๅธ็ๅจsanitize()้ถๆฎตไผไธขๅผ MTP ๆ้๏ผๅฏผ่ดๆ ๆณไฝฟ็จๆๆบ่งฃ็ ๅ ้ใ
Introduction
This is a 4-bit quantized MLX conversion of Qwen/Qwen3.6-27B with native MTP (Multi-Token Prediction) weights fully preserved.
Most pre-converted MLX models on HuggingFace (including mlx-community releases) remove MTP weights during the sanitize() step, making it impossible to use Qwen3.6's built-in speculative decoding acceleration. This model fixes that.
Why This Matters
Qwen3.6 models include a dedicated MTP head (an extra transformer layer) trained to predict token t+2 from the hidden state at t and the embedding of t+1. When enabled during inference:
- Speedup: ~1.5-2x faster generation compared to standard autoregressive decoding
- Quality: Zero quality loss โ MTP is trained end-to-end with the base model
- No draft model needed: Unlike DFlash or standard speculative decoding, MTP uses the model's own weights โ no separate draft model to load or manage
Official MLX conversions strip these weights because mlx-lm's sanitize() method drops mtp.* keys. This repository preserves them.
Model Details
| Property | Value |
|---|---|
| Base Model | Qwen/Qwen3.6-27B |
| Quantization | 4-bit affine, group_size=64 |
| Total Parameters | ~27B |
| Context Length | 262,144 |
| Architecture | Qwen3.5 (Gated DeltaNet hybrid) |
| MTP Layers | 1 |
| File Size | ~14.4GB (3 safetensors) |
| Compatible With | mlx-lm feat/mtp-batched branch |
Performance (M5 Max, 64GB RAM)
| Mode | Tokens/sec | Notes |
|---|---|---|
| Standard | ~30-35 | Baseline |
| MTP enabled | ~45-55 | ~1.5x speedup |
| MTP + DFlash | โ Incompatible | Cannot combine |
| MTP + TurboQuant KV | โ Incompatible | MTP needs exact attention path |
MTP acceptance rate observed: 74-84% in continuous conversation tests (15K+ tokens).
Required Branch / Version
You MUST use the feat/mtp-batched branch of mlx-lm. The official PyPI release and mlx-community conversions do NOT support MTP inference โ they strip mtp.* weights during sanitize().
| Component | Required Path / Branch |
|---|---|
mlx-lm install |
git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched |
| Model on HuggingFace | samwang0041/Qwen3.6-27B-MLX-4bit-MTP |
| Original base model | Qwen/Qwen3.6-27B |
# Install the exact branch
pip install git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched
Model Directory Structure
After mlx_lm.load() downloads or after manual conversion, the model directory contains:
qwen3.6-27b-4bit-mtp/
โโโ config.json # Model config (includes text_config.mtp_num_hidden_layers: 1)
โโโ tokenizer.json # BPE tokenizer
โโโ tokenizer_config.json
โโโ chat_template.jinja # Qwen3.6 chat template
โโโ model.safetensors.index.json # Weight map
โโโ model-00001-of-00003.safetensors # ~5.0GB (backbone layers 0-21)
โโโ model-00002-of-00003.safetensors # ~5.4GB (backbone layers 22-42 + lm_head)
โโโ model-00003-of-00003.safetensors # ~4.7GB (backbone layers 43-63 + MTP weights)
MTP weights are inside shard 3 under these keys (as seen in model.safetensors.index.json):
language_model.mtp.fc.weightlanguage_model.mtp.layers.0.input_layernorm.weightlanguage_model.mtp.layers.0.mlp.down_proj.weightlanguage_model.mtp.layers.0.mlp.gate_up_proj.weightlanguage_model.mtp.layers.0.post_attention_layernorm.weightlanguage_model.mtp.layers.0.self_attn.k_proj.weightlanguage_model.mtp.layers.0.self_attn.o_proj.weightlanguage_model.mtp.layers.0.self_attn.q_proj.weightlanguage_model.mtp.layers.0.self_attn.v_proj.weightlanguage_model.mtp.emb.weightlanguage_model.mtp.lm_head.weight- ... (31 total MTP weight keys)
How to Use
CLI generation:
python -m mlx_lm.generate \
--model samwang0041/Qwen3.6-27B-MLX-4bit-MTP \
--prompt "Explain quantum computing" \
--max-tokens 512 \
--mtp
Python API:
from mlx_lm import load, generate
# Auto-downloads from HuggingFace if not cached locally
model, tokenizer = load("samwang0041/Qwen3.6-27B-MLX-4bit-MTP")
response = generate(
model, tokenizer,
prompt="Explain quantum computing",
max_tokens=512,
verbose=True,
mtp=True, # Enable MTP speculative decoding
)
Load from local path:
# If you downloaded/converted manually
model, tokenizer = load("/path/to/qwen3.6-27b-4bit-mtp")
With omlx server:
Add to ~/.omlx/model_settings.json:
{
"qwen3.6-27b-4bit-mtp": {
"mtp_enabled": true,
"turboquant_kv_enabled": false,
"dflash_enabled": false,
"temperature": 1.0,
"top_p": 0.95,
"top_k": 20
}
}
The model directory should be placed at:
~/.omlx/models/qwen3.6-27b-4bit-mtp/
Conversion Process
This model was converted using the following steps:
# 1. Install mlx-lm with MTP support
pip install git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched
# 2. Download original weights and convert with quantization
python -m mlx_lm convert \
--hf-path Qwen/Qwen3.6-27B \
--mlx-path qwen3.6-27b-4bit-mtp \
-q --q-bits 4 --q-group-size 64
# 3. The key: feat/mtp-batched branch preserves mtp.* weights during sanitize()
# Official mlx-lm releases strip them, breaking speculative decoding
The conversion was performed on an Apple M5 Max with 64GB RAM. Original BF16 weights (54GB) were loaded and quantized to 4-bit (14.4GB).
KV Cache Stability
Extensively tested with continuous multi-turn conversations (10+ rounds, 15K+ tokens):
- โ No KV cache corruption
- โ No SSM state rollback errors
- โ Stable MTP acceptance rates across long sessions
- โ Suitable for production use as an OpenAI-compatible API server
Important Notes
- MTP vs DFlash: These are mutually exclusive. MTP uses the model's own weights; DFlash uses a separate draft model. Pick one.
- MTP vs TurboQuant KV: Also mutually exclusive. MTP requires exact attention computation paths; TurboQuant approximates KV cache, breaking MTP's draft validation.
- Only Qwen3.5/3.6 architecture: MTP is specific to Qwen3.5/3.6's architecture. Other models (Llama, Gemma, etc.) do not have this feature.
- Requires feat/mtp-batched branch: The official PyPI
mlx-lmdoes not support MTP inference yet.
Related Links
- mlx-lm MTP PR #990 โ Official MTP implementation PR
- feat/mtp-batched branch โ The branch used for conversion
- Qwen3.6 Official Repo
- MLX Documentation
License
This model follows the same license as the original Qwen/Qwen3.6-27B: Apache 2.0
The conversion and upload are provided as-is for community use. No warranties expressed or implied.
็ฎไป
่ฟๆฏ Qwen/Qwen3.6-27B ็ 4-bit MLX ้ๅ็ๆฌ๏ผๅฎๆดไฟ็ไบๅ็ MTP๏ผๅค Token ้ขๆต๏ผๆ้ใ
HuggingFace ไธๅคงๅคๆฐ้ข่ฝฌๆข็ MLX ๆจกๅ๏ผๅ
ๆฌ mlx-community ๅๅธ็๏ผๅจ sanitize() ้ถๆฎตไผ็งป้ค MTP ๆ้๏ผๅฏผ่ดๆ ๆณไฝฟ็จ Qwen3.6 ๅ
็ฝฎ็ๆๆบ่งฃ็ ๅ ้ใ่ฟไธชๆจกๅ่งฃๅณไบ่ฟไธช้ฎ้ขใ
ไธบไปไน้่ฆ
Qwen3.6 ๆจกๅๅ
ๅซไธไธชไธ้จ็ MTP Head๏ผ้ขๅค็ไธไธช Transformer ๅฑ๏ผ๏ผ่ฎญ็ป็ฎๆ ๆฏไปไฝ็ฝฎ t ็้่็ถๆ้ขๆต token t+2ใๅฏ็จๅ๏ผ
- ้ๅบฆๆๅ๏ผ็ธๆฏๆ ๅ่ชๅๅฝ่งฃ็ ๏ผ็ๆ้ๅบฆๆๅ็บฆ 1.5-2 ๅ
- ้ถ่ดจ้ๆๅคฑ๏ผMTP ไธๅบ็กๆจกๅ็ซฏๅฐ็ซฏ่ๅ่ฎญ็ป๏ผไธไผ้ไฝ่พๅบ่ดจ้
- ๆ ้่็จฟๆจกๅ๏ผไธ DFlash ๆๆ ๅๆๆบ่งฃ็ ไธๅ๏ผMTP ไฝฟ็จๆจกๅ่ช่บซ็ๆ้๏ผไธ้่ฆๅ ่ฝฝๅ็ฌ็่็จฟๆจกๅ
ๅฎๆน MLX ่ฝฌๆขไผไธขๅผ่ฟไบๆ้๏ผๅ ไธบ mlx-lm ็ sanitize() ๆนๆณไผ่ฟๆปคๆ mtp.* ้ฎใๆฌไปๅบๅฎๆดไฟ็ไบๅฎไปฌใ
ๆจกๅ่ฏฆๆ
| ๅฑๆง | ๅผ |
|---|---|
| ๅบ็กๆจกๅ | Qwen/Qwen3.6-27B |
| ้ๅๆนๅผ | 4-bit affine, group_size=64 |
| ๆปๅๆฐ้ | ~27B |
| ไธไธๆ้ฟๅบฆ | 262,144 |
| ๆถๆ | Qwen3.5๏ผGated DeltaNet ๆททๅ๏ผ |
| MTP ๅฑๆฐ | 1 |
| ๆไปถๅคงๅฐ | ~14.4GB๏ผ3 ไธช safetensors๏ผ |
| ๅ ผๅฎน็ฏๅข | mlx-lm feat/mtp-batched ๅๆฏ |
ๆง่ฝ่กจ็ฐ๏ผM5 Max, 64GB ๅ ๅญ๏ผ
| ๆจกๅผ | Tokens/็ง | ่ฏดๆ |
|---|---|---|
| ๆ ๅ่งฃ็ | ~30-35 | ๅบ็บฟ |
| ๅฏ็จ MTP | ~45-55 | ~1.5 ๅๅ ้ |
| MTP + DFlash | โ ไธๅ ผๅฎน | ไธ่ฝๅๆถๅผๅฏ |
| MTP + TurboQuant KV | โ ไธๅ ผๅฎน | MTP ้่ฆ็ฒพ็กฎ็ๆณจๆๅ่ทฏๅพ |
ๅจ่ฟ็ปญๅฏน่ฏๆต่ฏไธญ๏ผ15K+ tokens๏ผ๏ผMTP ๆฅๅ็็จณๅฎๅจ **74-84%**ใ
ๅฟ ้กปไฝฟ็จ็ๅๆฏ / ็ๆฌ
ๅฟ
้กปไฝฟ็จ mlx-lm ็ feat/mtp-batched ๅๆฏใ PyPI ๆญฃๅผ็ๅ mlx-community ็่ฝฌๆขๆจกๅไธๆฏๆ MTP ๆจ็ โ ๅฎไปฌไผๅจ sanitize() ้ถๆฎตไธขๅผ mtp.* ๆ้ใ
| ็ปไปถ | ๆ้่ทฏๅพ / ๅๆฏ |
|---|---|
mlx-lm ๅฎ่ฃ
|
git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched |
| HuggingFace ๆจกๅ | samwang0041/Qwen3.6-27B-MLX-4bit-MTP |
| ๅๅงๅบ็กๆจกๅ | Qwen/Qwen3.6-27B |
# ๅฎ่ฃ
ๆๅฎๅๆฏ
pip install git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched
ๆจกๅ็ฎๅฝ็ปๆ
mlx_lm.load() ่ชๅจไธ่ฝฝๆๆๅจ่ฝฌๆขๅ๏ผๆจกๅ็ฎๅฝ็ปๆๅฆไธ๏ผ
qwen3.6-27b-4bit-mtp/
โโโ config.json # ๆจกๅ้
็ฝฎ๏ผๅ
ๅซ text_config.mtp_num_hidden_layers: 1๏ผ
โโโ tokenizer.json # BPE ๅ่ฏๅจ
โโโ tokenizer_config.json
โโโ chat_template.jinja # Qwen3.6 ๅฏน่ฏๆจกๆฟ
โโโ model.safetensors.index.json # ๆ้ๆ ๅฐ่กจ
โโโ model-00001-of-00003.safetensors # ~5.0GB๏ผไธปๅนฒๅฑ 0-21๏ผ
โโโ model-00002-of-00003.safetensors # ~5.4GB๏ผไธปๅนฒๅฑ 22-42 + lm_head๏ผ
โโโ model-00003-of-00003.safetensors # ~4.7GB๏ผไธปๅนฒๅฑ 43-63 + MTP ๆ้๏ผ
MTP ๆ้ไฝไบๅ็ 3 ไธญ๏ผ้ฎๅๅฆไธ๏ผๅฏๅจ model.safetensors.index.json ไธญๆฅ็๏ผ๏ผ
language_model.mtp.fc.weightlanguage_model.mtp.layers.0.input_layernorm.weightlanguage_model.mtp.layers.0.mlp.down_proj.weightlanguage_model.mtp.layers.0.mlp.gate_up_proj.weightlanguage_model.mtp.layers.0.post_attention_layernorm.weightlanguage_model.mtp.layers.0.self_attn.k_proj.weightlanguage_model.mtp.layers.0.self_attn.o_proj.weightlanguage_model.mtp.layers.0.self_attn.q_proj.weightlanguage_model.mtp.layers.0.self_attn.v_proj.weightlanguage_model.mtp.emb.weightlanguage_model.mtp.lm_head.weight- ...๏ผๅ ฑ 31 ไธช MTP ๆ้้ฎ๏ผ
ไฝฟ็จๆนๆณ
ๅฝไปค่ก็ๆ๏ผ
python -m mlx_lm.generate \
--model samwang0041/Qwen3.6-27B-MLX-4bit-MTP \
--prompt "่งฃ้้ๅญ่ฎก็ฎ" \
--max-tokens 512 \
--mtp
Python API๏ผ
from mlx_lm import load, generate
# ๅฆๆชๆฌๅฐ็ผๅญ๏ผ่ชๅจไป HuggingFace ไธ่ฝฝ
model, tokenizer = load("samwang0041/Qwen3.6-27B-MLX-4bit-MTP")
response = generate(
model, tokenizer,
prompt="่งฃ้้ๅญ่ฎก็ฎ",
max_tokens=512,
verbose=True,
mtp=True, # ๅฏ็จ MTP ๆๆบ่งฃ็
)
ไปๆฌๅฐ่ทฏๅพๅ ่ฝฝ๏ผ
# ๅฆๆไฝ ๆๅจไธ่ฝฝๆ่ฝฌๆข่ฟ
model, tokenizer = load("/path/to/qwen3.6-27b-4bit-mtp")
้ ๅ omlx ๆๅกๅจ๏ผ
ๅจ ~/.omlx/model_settings.json ไธญๆทปๅ ๏ผ
{
"qwen3.6-27b-4bit-mtp": {
"mtp_enabled": true,
"turboquant_kv_enabled": false,
"dflash_enabled": false,
"temperature": 1.0,
"top_p": 0.95,
"top_k": 20
}
}
ๆจกๅ็ฎๅฝๅบๆพ็ฝฎๅจ๏ผ
~/.omlx/models/qwen3.6-27b-4bit-mtp/
่ฝฌๆข่ฟ็จ
ๆฌๆจกๅ้่ฟไปฅไธๆญฅ้ชค่ฝฌๆข๏ผ
# 1. ๅฎ่ฃ
ๆฏๆ MTP ็ mlx-lm
pip install git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-batched
# 2. ไธ่ฝฝๅๅงๆ้ๅนถ่ฟ่ก้ๅ่ฝฌๆข
python -m mlx_lm convert \
--hf-path Qwen/Qwen3.6-27B \
--mlx-path qwen3.6-27b-4bit-mtp \
-q --q-bits 4 --q-group-size 64
# 3. ๅ
ณ้ฎ็น๏ผfeat/mtp-batched ๅๆฏๅจ sanitize() ๆถไฟ็ไบ mtp.* ๆ้
# ๅฎๆน mlx-lm ๅๅธ็ไผไธขๅผๅฎไปฌ๏ผๅฏผ่ดๆๆบ่งฃ็ ๅคฑๆ
่ฝฌๆขๅจ Apple M5 Max๏ผ64GB ๅ ๅญ๏ผไธๅฎๆใๅๅง BF16 ๆ้็บฆ 54GB๏ผ้ๅๅ็บฆ 14.4GBใ
KV Cache ็จณๅฎๆง
็ป่ฟๆ็ปญๅค่ฝฎๅฏน่ฏ็ๅ ๅๆต่ฏ๏ผ10+ ่ฝฎ๏ผ15K+ tokens๏ผ๏ผ
- โ ๆ KV cache ๆๅ
- โ ๆ SSM ็ถๆๅๆป้่ฏฏ
- โ ้ฟไผ่ฏไธญ MTP ๆฅๅ็็จณๅฎ
- โ ๅฏไฝไธบ OpenAI ๅ ผๅฎน API ๆๅกๅจ็จไบ็ไบง็ฏๅข
้่ฆๆ็คบ
- MTP ไธ DFlash ไบๆฅ๏ผไบ่ ๅช่ฝ้ไธไธชใMTP ไฝฟ็จๆจกๅ่ช่บซๆ้๏ผDFlash ไฝฟ็จ็ฌ็ซ็่็จฟๆจกๅใ
- MTP ไธ TurboQuant KV ไบๆฅ๏ผMTP ้่ฆ็ฒพ็กฎ็ๆณจๆๅ่ฎก็ฎ่ทฏๅพ๏ผTurboQuant ๅฏน KV cache ๅ่ฟไผผ๏ผไผ็ ดๅ MTP ็่็จฟ้ช่ฏใ
- ไป ๆฏๆ Qwen3.5/3.6 ๆถๆ๏ผMTP ๆฏ Qwen3.5/3.6 ็นๆ็ๅ่ฝ๏ผๅ ถไปๆจกๅ๏ผLlamaใGemma ็ญ๏ผๆฒกๆๆญค็นๆงใ
- ้่ฆ feat/mtp-batched ๅๆฏ๏ผPyPI ไธ็ๆญฃๅผ็
mlx-lmๅฐไธๆฏๆ MTP ๆจ็ใ
็ธๅ ณ้พๆฅ
- mlx-lm MTP PR #990 โ ๅฎๆน MTP ๅฎ็ฐ PR
- feat/mtp-batched ๅๆฏ โ ่ฝฌๆขไฝฟ็จ็ๅๆฏ
- Qwen3.6 ๅฎๆนไปๅบ
- MLX ๆๆกฃ
่ฎธๅฏ่ฏ
ๆฌๆจกๅ้ตๅพชๅๅงๆจกๅ Qwen/Qwen3.6-27B ็่ฎธๅฏ่ฏ๏ผApache 2.0
่ฝฌๆขๅไธไผ ไป ไพ็คพๅบไฝฟ็จ๏ผไธไฝไปปไฝๆ็คบๆๆ็คบ็ๆ ไฟใ
Tags: mlx, qwen, qwen3.6, mtp, multi-token-prediction, speculative-decoding, mlx-lm, apple-silicon, 4bit, quantized, local-llm, inference-acceleration
Keywords: Qwen3.6 MLX conversion, native MTP weights, speculative decoding, multi-token prediction, mlx-lm mtp branch, omlx, Apple Silicon inference, Qwen 27B 4bit, local LLM deployment
- Downloads last month
- 112
4-bit
Model tree for samwang0041/Qwen3.6-27B-MLX-4bit-MTP
Base model
Qwen/Qwen3.6-27B