Paris99's picture
Card: add 'Which build fits my Mac?'
5b0b84a verified
|
Raw History Blame Contribute Delete
10.9 kB
---
license: apache-2.0
base_model: harness-hub/Qwen3.8-27B-opencode-adapted
base_model_relation: quantized
pipeline_tag: image-text-to-text
library_name: mlx
tags:
- mlx
- apple-silicon
- agents
- coding-agent
- opencode
- lora
---
# Qwen3.8-27B-opencode-adapted for Apple Silicon (MLX, 4-bit)
[harness-hub/Qwen3.8-27B-opencode-adapted](https://huggingface.co/harness-hub/Qwen3.8-27B-opencode-adapted) (revision `b4171c0`) merged into
[Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) (revision `3756181`) and converted to MLX with mlx-vlm, vision
encoder and Qwen's MTP layer included. In this build the linear layers are quantized to 4-bit (affine, group 64). Size: 16.3 GB.
harness-hub trained this LoRA with reinforcement learning (AsyncGRPO in TRL) to be the model behind the
[OpenCode](https://opencode.ai) coding agent on software-engineering and terminal tasks. Their published results, under
OpenCode with thinking off: **SWE-bench Pro (hard 51) 35.3% → 51.0%** and **Terminal-Bench 2.1 46.4% → 52.4%** against
the base model, and with thinking off it matches the base model thinking at its highest effort while generating about
a sixth of the tokens. See the [original adapter card](https://huggingface.co/harness-hub/Qwen3.8-27B-opencode-adapted)
for the method, data and full results.
| Build | Size | Same next token as bf16 | KL vs bf16 |
|---|---|---|---|
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-6bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-6bit) (recommended) | 23.1 GB | 98.7% | 0.0014 |
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-8bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-8bit) | 30.0 GB | 99.2% | 0.0004 |
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit) | 16.3 GB | 96.7% | 0.0203 |
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-3bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-3bit) | 13.8 GB | 93.4% | 0.0812 |
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-bf16](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-bf16) | 55.6 GB | reference | reference |
| [netprojects/Qwen3.8-27B-opencode-adapted-MLX-adapter](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-adapter) | 638 MB | LoRA only, for mlx-lm | on any Qwen3.8-27B MLX build |
The 6-bit build is the recommended balance of size and fidelity; 8-bit is closest to bf16; 4-bit and 3-bit are for Macs with less memory (3-bit fits 24 GB Macs).
<!-- mac-picker:start -->
## Which build fits my Mac?
Each pick leaves room for macOS and a long prompt (the download is at most about 60% of your memory). Other models for your Mac: [which build fits my Mac?](https://huggingface.co/netprojects).
| Your Mac | MLX (mlx-lm, mlx-vlm, LM Studio MLX) | GGUF (llama.cpp, Ollama, LM Studio) |
|---|---|---|
| 16 GB ⚡ stretch | – | [IQ2_M](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-GGUF) (10.2 GB) |
| 24 GB | [3-bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-3bit) (13.8 GB) | [Q3_K_M](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-GGUF) (13.5 GB) |
| 32 GB | **[4-bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit) (16.3 GB)** (this build) | [Q4_K_M](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-GGUF) (16.8 GB) |
| 48 GB | [6-bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-6bit) (23.1 GB, recommended) | [Q6_K](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-GGUF) (22.4 GB) |
| 64 GB and up | [8-bit](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-8bit) (30.0 GB) | [Q8_0](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-GGUF) (29.0 GB) |
| 128 GB, reference | [bf16](https://huggingface.co/netprojects/Qwen3.8-27B-opencode-adapted-MLX-bf16) (55.6 GB) | – |
⚡ *Stretch:* close other apps, keep prompts to a few thousand tokens, and let the GPU use more memory with `sudo sysctl iogpu.wired_limit_mb=12800` (lasts until restart).
<!-- mac-picker:end -->
## Use with OpenCode
The adapter was trained and evaluated with **thinking off**, so keep it off. Serve the model with mlx-lm's
OpenAI-compatible server:
```bash
pip install -U "mlx-lm>=0.32.2"
mlx_lm.server --model netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit --port 8000 \
--chat-template-args '{"enable_thinking": false}'
```
Add it to `~/.config/opencode/opencode.json`:
```json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"local": {
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "http://localhost:8000/v1", "apiKey": "dummy" },
"models": { "netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit": {} }
}
}
}
```
```bash
opencode run --model local/netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit "Find out why the tests in tests/test_parser.py fail and fix the bug."
```
## Use from Python
Text only, with mlx-lm:
```python
from mlx_lm import load, generate
model, tokenizer = load("netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit")
messages = [{"role": "user", "content": "Write a Python function that parses '1.5M' into bytes."}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False, tokenize=False)
print(generate(model, tokenizer, prompt=prompt, max_tokens=512))
```
With images, with mlx-vlm:
```bash
pip install -U "mlx-vlm>=0.7.11"
mlx_vlm.generate --model netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit --image screenshot.png \
--prompt "What error does this terminal show?" --max-tokens 300 # thinking stays off unless --enable-thinking
```
The tokenizer and chat template are harness-hub's files, unchanged (same vocabulary and tool-call format as Qwen3.8-27B).
Tool calls use Qwen's XML format (`<tool_call><function=...><parameter=...>`), which mlx-lm's server returns as
OpenAI `tool_calls`.
## Faster decoding: MTP and DSpine
This build keeps Qwen3.8-27B's own multi-token-prediction (MTP) layer in `model-mtp.safetensors`, quantized to match
the build. The adapter does not change that layer, so it is Qwen's original MTP head. mlx-vlm uses it as a built-in
draft model when you pass the same repository as `--draft-model`:
```bash
mlx_vlm.generate --model netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit --draft-model netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit \
--draft-kind mtp --temperature 0 --max-tokens 512 --prompt "Write a Python function that checks whether a number is prime."
```
On this build MTP makes decoding about 1.9× faster with no extra download. The [DSpine drafter](https://huggingface.co/netprojects/Qwen3.8-27B-DSpine-b16-MLX) with
[dspine-hybrid-mlx](https://github.com/internet-projects/dspine-hybrid-mlx) also works with these builds. Our
measurements (greedy, thinking off, 5 prompts × 256 tokens from GSM8K, MATH-500, HumanEval, MBPP and MT-Bench, with
other services running on the Mac, so treat them as indicative):
| Build | Plain | MTP (mlx-vlm 0.7.11) | DSpine v0.2.1 (4-bit drafter, block 5) |
|---|---|---|---|
| 4-bit | 33 tok/s | 62 tok/s (×1.91) | 73 tok/s (×2.29) |
| 6-bit | 20 tok/s | 21 tok/s (×1.04) | 60 tok/s (×2.72) |
| 8-bit | 17 tok/s | 37 tok/s (×2.15) | 54 tok/s (×3.03) |
Both methods check every drafted token with the full model. With greedy decoding the text matches plain decoding
until a near-tie, where the batched check can round the other way, so long answers can diverge slightly.
### With Splash
These builds also run in Splash (1.7.0), which uses its own DFlash2 draft model for speculative decoding. Measured on the same 5 prompts × 256 tokens, thinking off, on 19 November 2026 with other models loaded on the Mac, so treat the speeds as indicative; text, tool calling and image input passed on every build:
| Build | Decode speed | End to end, incl. prompt | Tokens per cycle |
|---|---|---|---|
| 4-bit | 156 tok/s | 123 tok/s | 6.7 |
| 6-bit | 132 tok/s | 100 tok/s | 6.8 |
| 8-bit | 109 tok/s | 85 tok/s | 6.6 |
```bash
hf download netprojects/Qwen3.8-27B-opencode-adapted-MLX-4bit --local-dir Qwen3.8-27B-opencode-adapted-MLX
splash serve --model-dir Qwen3.8-27B-opencode-adapted-MLX --model local/qwen3.8-opencode --reasoning-effort none
```
Splash loads the quantized builds (4, 6 and 8-bit); it does not load bf16 MLX checkpoints.
## What was checked
On a MacBook Pro M5 Max (128 GB), 18 November 2026, with mlx 0.32.4, mlx-lm 0.32.2 and mlx-vlm 0.7.11.
- **Merge.** All 256 adapted modules (q, k, v, o in the 16 full-attention layers; gate, up, down in all 64 layers) equal `W + 2.0 · B @ A` rounded to bf16, checked element by element against an independent float64 computation; every other tensor is byte-identical to Qwen3.8-27B. The adapter does not touch the vision encoder or the Gated DeltaNet layers.
- **Quantization.** Each quantized build is checked to be exactly the affine (group 64) quantization of the bf16 build.
- **Agreement with bf16** (12 short prompts, thinking off, 949 teacher-forced positions): the 8-bit build picks the same next token as bf16 on 99.2% of positions, 6-bit on 98.7% and 4-bit on 96.7% (mean KL 0.0004 / 0.0014 / 0.0203).
- **Tool calling** with the included chat template, thinking off: one agent-style prompt with `bash` and `read` tools; 8-bit, 6-bit, 4-bit each produced a well-formed `bash` tool call in Qwen's XML format.
- **Coding.** Three short Python tasks run against asserts: 8-bit 3/3, 6-bit 3/3, 4-bit 3/3.
- **Vision** (mlx-vlm): asked to name the shapes and colours in a test image, 8-bit, 6-bit, 4-bit answered correctly, and answered a text-only question in the same session.
- **MTP layer.** The bundled MTP tensors equal Qwen3.8-27B's `mtp.*` weights (norms in mlx-vlm's stored form), quantized exactly like the rest of the build; each build loads normally in mlx-lm and mlx-vlm with the extra file present.
- **Source files.** Every file of both pinned upstream revisions matches the Hub's SHA-256 hashes.
## Credits
The adapter is by harness-hub; the base model is Qwen3.8-27B by the Qwen Team, Alibaba Cloud. If you use the model,
please cite their work (see the [adapter card](https://huggingface.co/harness-hub/Qwen3.8-27B-opencode-adapted) and the
[Qwen3.8-27B card](https://huggingface.co/Qwen/Qwen3.8-27B)).
## License
Apache-2.0, as Qwen3.8-27B and the harness-hub adapter. `LICENSE` is the Apache-2.0 text from the Qwen3.8-27B repository
and `NOTICE` describes the conversion and credits harness-hub and the Qwen Team (Alibaba Cloud).
Published by [NetProjects](https://netprojects.com) (Internet Projects Ltd). Not affiliated with Hugging Face, harness-hub or Alibaba.
More MLX builds from NetProjects: [huggingface.co/netprojects](https://huggingface.co/netprojects) · [netprojects.com](https://netprojects.com)