Ternary Bonsai 2 9B — MTPLX pack (EngineeringWithJay)
This is our own repackaging of Prism ML's official
Ternary-Bonsai-2-9B-mlx-2bit
into the MTPLX pack contract, so that the 9B can be served with native MTP
speculative decoding on Apple silicon instead of only through Prism's bundled
mlx-vlm runtime.
No weight bytes were changed. The trunk is byte-identical to the upstream
pack (model.safetensors sha256 b8ebd13459dcd53504432a4a0a797287…, 3,462,149,260 bytes)
and the MTP head is Prism's own qwen3_5_mtp 4-bit g64 head with its 31 tensors
unchanged. We changed packaging and identity metadata only.
Why we made it
We wanted a fast local model for visual agentic coding. On this Mac (M5 Air, 16 GB) the 27B Swift pack we serve reaches ~23 t/s and needs 8.2 GB of weights; this 9B needs 3.4 GB and runs at 53.4 t/s, which leaves room in the same 16 GB for a long KV cache. The trade is knowledge: this is the base Ternary Bonsai 2 9B, not a Swift (DPO) derivative.
Measured on this machine
All numbers from one M5 Air (16 GB unified memory), MTPLX 2.12.3, one model resident, thinking disabled:
| measurement | result |
|---|---|
| text decode | 53.4 t/s |
| decode with an image in the prompt | 30.4 t/s |
| largest prompt accepted | 63,133 tokens (a fresh ~95K prefill hit a 507 insufficient-memory abort on this 16 GB host) |
| conversation turn after the first | 0.6 s for a 16K-token conversation, because the KV prefix is restored from the session bank instead of re-prefilled (14.1 s on the first turn) |
| vision | read GROUND TRUTH 42 verbatim from a rendered PNG; read all four ANSI-coloured test verdicts (FAIL/PASS/WARN) by colour from a terminal image; read every value of a real UI viewport screenshot correctly |
Vision
This pack carries Prism's genuine vision tower for the Ternary Bonsai 2 9B
lineage (hidden 4096, 27 blocks, 1152-wide, 4-bit HQQ), so it is a real
vision-language model rather than a text model with a grafted tower. Images go
in through the OpenAI-compatible API as image_url parts with a data: URL.
How to serve it
Requires MTPLX 2.12+ (mtplx serve). Plain mlx-lm cannot load this pack:
its model_type is prism_hadamard_qwen35, which carries the Hadamard/sign-flip
integration the format needs.
mtplx serve \
--model /path/to/Ternary-Bonsai-2-9B-MTPLX \
--port 8002 --cache-dir /path/to/models \
--reasoning off --allow-swap \
--mtp --generation-mode mtp \
--mtp-batch-numerics throughput --draft-core device \
--scheduler-mode hyper --batching-preset latency \
--paged-kv-quantization q4 \
--ssd-session-cache on --ssd-session-cache-dir /path/to/ssd-bank \
--ssd-session-cache-max-size 30G
Two environment variables matter on a 16 GB Mac:
export MTPLX_MEMORY_LIMIT_BYTES=14495552000 # engine budget (Metal limit is 13.5G)
export MTPLX_SESSION_BANK_MAX_BYTES=3221225472 # 3G bank budget enables KV prefix reuse
Do not lower the session bank budget to 64 MB. With a small budget the bank cannot hold one conversation entry (a 14K-token entry needs ~989 MB), so the prefix is never reused and every turn re-prefills the whole conversation — 14.1 s per turn instead of 0.6 s on the same workload.
Check the pack before serving:
mtplx inspect --model /path/to/Ternary-Bonsai-2-9B-MTPLX
# tier: verified | can_run: true | runtime_compatibility: native | mtp_layers: 1
What we changed relative to the upstream pack
Four packaging changes, all verified by mtplx inspect:
mtp/model.safetensorsmoved tomtp.safetensorsat the pack root, because MTPLX looks for the sidecar there.- Its 31 tensor keys were given the
mtp.prefix (fc.weight→mtp.fc.weight). Prism ships them unprefixed for mlx-vlm; MTPLX expects the prefix. config.jsongainedmtplx_mtp_contract,mtplx_mtp_quantization(bits 4, group size 64, mode affine, policy all, prequantized true),mlx_lm_extra_tensors.mtp_file,model_family, andtext_config.mtp_num_hidden_layers = 1.mtplx_runtime.jsonwas written, withexactness_baselineciting Prism's own reload validation (all 248,320 logits exact after reload, 202 packed modules, tokenizer ids and BPE merges matching).
The tensor namespace was already language_model.* + vision_tower.*, matching
MTPLX's contract, and components.mtp was set to true to match the sidecar we
ship.
Architecture
| property | value |
|---|---|
| family | Ternary Bonsai 2 9B (Prism ML), prism_hadamard_qwen35 |
| trunk quantization | 2-bit ternary, affine, group size 128 |
| hidden size | 4096 |
| layers | 32 (8 full-attention, 24 linear-attention / Gated DeltaNet) |
| attention heads | 16 attention / 4 key-value, head_dim 256 |
| MTP head | qwen3_5_mtp, 4-bit group-64 affine, prequantized, depth 1 |
| context | 262,144 native |
| KV per token | 32 KB bf16 (16 full-attention layers would be 64 KB; the 9B has 8) |
| vision tower | 27 blocks, hidden 1152, 4-bit HQQ |
Limitations
- This is the base model. It is not a Swift finetune and does not have Swift's reduced thinking tokens or its post-training.
- The MTP head is Prism's own, trained against the Ternary Bonsai 2 trunk, so acceptance here is the upstream head's acceptance for this lineage. We measured decode rates on this machine but did not publish a separate acceptance-rate table.
- The ~95K fresh-prefill abort above is a property of this 16 GB host, not of the pack: the model declares 262,144 native context and MTPLX's own plan for this pack reported a 65,536-token fit under q4 KV.
components.visionis true because this lineage genuinely has a vision tower. We verified text-image reading, not video or multi-image behaviour.
License and attribution
Apache-2.0. The weights are Prism ML's, redistributed unchanged; our
repackaging (README, mtplx_runtime.json, config.json additions, packaging)
is also Apache-2.0. See NOTICE.txt for the full attribution chain and
LICENSE for the licence text.
Citation
@misc{engineeringwithjay_ternary_bonsai2_9b_mtplx,
title = {Ternary Bonsai 2 9B -- MTPLX pack},
author = {EngineeringWithJay},
year = {2026},
note = {MTPLX-native repackaging of prism-ml/Ternary-Bonsai-2-9B-mlx-2bit; weight bytes unchanged},
url = {https://huggingface.co/EngineeringWithJay/Ternary-Bonsai-2-9B-MTPLX}
}