Ternary Bonsai 2 4B — MTPLX pack (EngineeringWithJay)
Our own repackaging of Prism ML's official
Ternary-Bonsai-2-4B-mlx-2bit
into the MTPLX pack contract, with Prism's own 4B MTP head attached, so the 4B
can be served with native MTP speculative decoding on Apple silicon.
No weight bytes were changed. The trunk is byte-identical to the upstream
pack (model.safetensors sha256 432f48d0edcb8da2e6a4e0c960785883…, 1,871,365,704 bytes).
Measured on this machine
One M5 Air (16 GB unified memory), MTPLX 2.12.3, one model resident, thinking disabled:
| measurement | result |
|---|---|
| mean decode over 5 prompts | 43.9 t/s |
| fastest prompt | 64.8 t/s |
| decode with an image in the prompt | 35.9 t/s |
| vision | read a real UI viewport screenshot's values correctly (Temperature 0.60, Top P 0.95, Top K 20, MTP on, Draft depth 1, Max tokens 16.4k) |
MTP and the tied output projection
Prism ships the 4B with tie_word_embeddings: true and no lm_head tensors: the
output projection is the embedding. MTPLX's draft-head builder
(draft_lm_head._make_embedding_as_linear_head) only accepted nn.Embedding and
nn.QuantizedEmbedding, so it raised TypeError on MTPLX's own
HadamardQuantizedEmbedding — and it is hit even with --no-mtp, so a tied pack
could not be served at all.
The 4B therefore needs a one-branch patch to MTPLX. It is not a change to this pack:
# mtplx/draft_lm_head.py, in _make_embedding_as_linear_head, before the final raise
elif hasattr(module, "as_linear"):
# MTPLX's own HadamardQuantizedEmbedding: a tied Bonsai-2 output
# projection. It already exposes as_linear(), which rotates the input
# forward and reuses the stored packed matrix, so the draft head is
# the target's own tied head, exactly.
original = _embedding_report(module)
return _EmbeddingAsLinear(module), {
"source": "tied_embedding",
"original": original,
"draft_only": original,
"reused_existing_quantization": True,
"elapsed_s": time.perf_counter() - started,
}
With that branch the 4B loads with mtp_layers: 1 and tier: verified. The
untied 9B and 27B packs need no patch. The same fix is what makes any tied
Bonsai-2 size (the 2B) servable at all.
How to serve it
Requires MTPLX 2.12+ with the branch above (or a future release that includes it).
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-4B-MTPLX \
--port 8003 --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
On a 16 GB Mac also set:
export MTPLX_MEMORY_LIMIT_BYTES=14495552000
export MTPLX_SESSION_BANK_MAX_BYTES=3221225472
Do not lower the session bank budget to 64 MB. The bank cannot hold one conversation entry below roughly 1 GB, 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 16K-token workload).
Verify before serving:
mtplx inspect --model /path/to/Ternary-Bonsai-2-4B-MTPLX
# tier: verified | can_run: true | runtime_compatibility: native | mtp_layers: 1
What we changed relative to the upstream pack
Packaging only, all four verified by mtplx inspect:
mtp/model.safetensorsmoved tomtp.safetensorsat the pack root.- 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. Payloads unchanged. 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 with the keys MTPLX requires (mtplx_version,arch_id,mtp_depth_max,recommended_profile,exactness_baseline,verified_on).
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 4B (Prism ML), prism_hadamard_qwen35 |
| trunk quantization | 2-bit ternary, affine, group size 128 |
| hidden size | 2560 |
| layers | 32 (8 full-attention, 24 linear-attention / Gated DeltaNet) |
| attention heads | 16 attention / 4 key-value, head_dim 256 |
| intermediate size | 9216 |
| output projection | tied to the embedding (tie_word_embeddings: true) |
| MTP head | qwen3_5_mtp, 4-bit group-64 affine, prequantized, depth 1 |
| context | 262,144 native |
| KV per token | 32 KB bf16 (8 full-attention layers x 2 x 4 heads x 256 dim x 2 bytes) |
| vision tower | 24 blocks, hidden 1024 |
Limitations
- This is the base model, not a Swift finetune.
- The MTP head is Prism's own, trained against the Ternary Bonsai 2 trunk. We measured decode rates on this machine but did not publish a separate acceptance-rate table.
- The MTP draft-head patch above is required on MTPLX 2.12.3.
- 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_4b_mtplx,
title = {Ternary Bonsai 2 4B -- MTPLX pack},
author = {EngineeringWithJay},
year = {2026},
note = {MTPLX-native repackaging of prism-ml/Ternary-Bonsai-2-4B-mlx-2bit; weight bytes unchanged},
url = {https://huggingface.co/EngineeringWithJay/Ternary-Bonsai-2-4B-MTPLX}
}