Back to research

Project O27 set out to answer a concrete systems and modeling question for private mobile AI: how close can we get to frontier-grade local reasoning, unit-tested coding, and multi-turn agentic tool calling inside a strict sub-2.2 GB mobile memory budget—specifically targeting an Apple A15 Bionic class device with 4 GB to 6 GB of total RAM?

We attacked the problem from both ends. Starting from a 1-bit 27-billion-parameter baseline (Bonsai-27B-Q1_0.gguf, 3.54 GiB), we built a lean standalone runner, a lossless 214 MB GGUF SSD-sharding pipeline with speculative drafting under 1 GB RAM, and a lossless BPE vocabulary trimmer that cuts 272.7 MiB with zero accuracy loss. Then we built 5 deterministic, programmatically graded benchmarks (61 total scored points, including an author-designed 10-tool cyber-defense gauntlet to guard against benchmark saturation) and evaluated 5 compact models head-to-head.

60 / 61 98.4% winning score for Ternary-Bonsai-2-9B-PTQ1_0
1.86 GiB 2.00 GB standalone footprint (2.02 GB VRAM at 4K ctx)
0 errors Perfect 36 / 36 across abstention & 3 agentic gauntlets
12× less RAM Standalone runner cut 27B RAM from 13.0 GB to 1.03 GB

The decisive finding was unexpected: after proving bit-identical 27B inference under 1 GB RAM through aggressive sharding and vocabulary compression, an unmodified standalone ternary 9B model—PrismML’s Ternary-Bonsai-2-9B-PTQ1_0.gguf (1.86 GiB)—won outright. It tied the 3.54 GiB 27B baseline on our 25-eval multipurpose suite (24 / 25, 96.0%), outscored Orion’s outgoing Qwen3.5-4B-Q3_K_M model (60 / 61 vs. 59 / 61) in a smaller file, made zero errors across every stateful multi-turn gauntlet, and fits natively in RAM on a 4 GB A15 Bionic with no SSD streaming, no draft model, and no vocabulary trimming.

Test environment and deployment target

All systems measurements and deterministic evaluations were run on an AMD Ryzen 9 8945HX (16 cores / 32 threads) with 31.3 GB System RAM and an NVIDIA GeForce RTX 5070 Laptop GPU (8 GB VRAM). While desktop silicon enabled rapid iteration across all 5 suites, every architecture decision was evaluated against a strict mobile deployment target: Apple A15 Bionic (4 GB–6 GB RAM) with a sub-2.2 GB active model memory envelope.

Systems engineering and compression experiments

Before comparing smaller models, we pushed the Bonsai-27B-Q1_0.gguf (3.54 GiB, 1-bit qwen35) baseline as far as systems engineering alone could take it across three independent layers: runtime overhead, hard-capped SSD sharding, and lossless vocabulary compression.

1. Eliminating runtime overhead (run_o27.py)

Default desktop GUI stacks carry substantial hidden memory costs. Loading Bonsai-27B-Q1_0.gguf with LM Studio’s defaults—4 parallel slots (--parallel 4), a 16,384-token f16 KV cache, --load-mode mmap+mlock, and the 0.87 GB vision projector (mmproj)—consumed 12.16–13.03 GB of System RAM and 5.94 GB of VRAM.

Replacing that stack with a zero-dependency Python runner driving standalone llama-server with lean settings (--n-gpu-layers 99, --parallel 1, --ctx-size 4096, --cache-type-k/v q8_0, --flash-attn on, --no-mmap, and no mmproj) reduced peak System RAM by roughly 12× while increasing generation throughput by +67%.

Bonsai-27B-Q1_0.gguf (256 generated tokens): default GUI stack vs. lean standalone runner.
Metric LM Studio (Default) Lightweight Runner (run_o27.py) Improvement
Generation speed 23.1–24.2 tok/s 39.42 tok/s +67% faster
Prompt processing speed — 167.16 tok/s —
Peak System RAM (Working Set) 12.16–13.03 GB 1.03 GB (1.06 GB incl. Python) ~12× lower RAM
Peak GPU VRAM 5.94 GB 3.90 GB -34% VRAM

2. 214 MB SSD-offloaded sharding and speculative decoding

To test whether a 27B model can execute losslessly inside a strict sub-1 GB RAM ceiling with 0 MB GPU VRAM, we split Bonsai-27B-Q1_0.gguf into 18 native GGUF v3 shards (shard_split.py): Shard 1 holds metadata and token_embd.weight (180.9 MiB), Shards 2–17 each hold one hybrid 4-layer block (blk.0..3 through blk.60..63, 204.7 MiB / 214.7 MB per shard), and Shard 18 holds output_norm.weight and output.weight (170.5 MiB).

Running CPU-only memory-mapped inference (--load-mode mmap --device none --n-gpu-layers 0) inside a hard Win32 physical RAM cap (SetProcessWorkingSetSizeEx with QUOTA_LIMITS_HARDWS_MAX_ENABLE) forces the OS to evict earlier 214 MB shards back to SSD as later layers fault in. Pairing the sharded 27B verifier with a RAM-resident Qwen3.5-0.8B-Q4_K_M.gguf draft model (503.1 MiB, sharing the exact 248,320-token Qwen 3.5 tokenizer) cut SSD page faults in half and more than doubled decode speed while preserving bit-identical 27B outputs.

Lossless 27B inference under 1 GB RAM (32 generated tokens, 0 MB GPU VRAM).
Metric Plain SSD Shards (shard_runner.py) Speculative SSD Shards (speculative_shard_runner.py) Delta
Hard RAM cap 420 MB 950 MB (incl. 503 MiB draft) < 1 GB total
Measured peak resident RAM 420.1 MB (0.410 GB) 950.1 MB (0.928 GB) Held to the MB
SSD page faults during inference 30,443,227 15,061,385 -50.5% I/O
Wall-clock time 151.13 s 75.04 s 2.01× faster
Generation speed 0.22 tok/s 0.50 tok/s 2.26× faster
Draft acceptance — 19 / 48 (39.6%) Bit-identical 27B output

3. Lossless English + Code BPE vocabulary trimming (trim_vocab.py)

Large multilingual vocabularies represent a major fixed memory tax on compact models. Because both Bonsai-27B-Q1_0 and Qwen3.5-0.8B share Qwen 3.5’s 248,320-token BPE vocabulary, we built a shared vocabulary trimmer that computes a single keep-list retaining all 256 single-byte fallback tokens, all control and special tokens (<|im_start|>, <|im_end|>, <think>, tool tags, BOS/EOS/PAD), all pure-ASCII tokens plus common math and typographic symbols, and full transitive BPE merge closure so no kept merged token loses a constituent sub-token. Rows of token_embd.weight and output.weight are sliced directly in raw quantized bytes with zero requantization.

Shared BPE vocabulary trimming across verifier and draft model (zero requantization).
Model Original Vocab / Size Trimmed (-en) Vocab / Size Saved
Bonsai-27B-Q1_0-en.gguf 248,320 / 3,627.3 MiB 128,492 (51.7%) / 3,456.6 MiB -170.6 MiB
Qwen3.5-0.8B-Q4_K_M-en.gguf 248,320 / 503.1 MiB 128,492 (51.7%) / 401.0 MiB -102.1 MiB
Combined 4.03 GiB 3.77 GiB -272.7 MiB (286 MB)

Verified together under speculative decoding (--spec-type draft-simple), the trimmed pair scored 13 / 14 across Core Math (3/4), Core Coding (4/4), and Single-Turn Tool Use (6/6)—an exact match to the untrimmed baseline with zero accuracy loss and full speculative compatibility.

Custom deterministic benchmark architecture

Public leaderboards rarely capture the failure modes that break on-device assistants: misfiring tools on everyday questions, looping on error messages, ignoring schema constraints, or falling for distractors across a 10-turn stateful workflow. We built 5 deterministic benchmarks totaling 61 scored points, all run at temperature = 0.0 and seed = 42 with native --jinja OpenAI-compatible tool calling and 100% programmatic grading (zero LLM-as-a-judge variance):

Evaluation results

25-Eval Multipurpose Suite (5 Models)

Across the 25-task multipurpose suite, both Ternary-Bonsai-2-9B-PTQ1_0 (1.86 GiB) and Bonsai-8B-Q1_0 (1.08 GiB) matched the 3.54 GiB Bonsai-27B-Q1_0 baseline at 24 / 25 (96.0%), outperforming Qwen3.5-4B-Q3_K_M (23 / 25) and Ternary-Bonsai-2-4B-PQ2_0 (22 / 25) while running significantly faster and using roughly half the VRAM of the 27B baseline.

25-Eval Multipurpose Suite results (temperature = 0.0, seed = 42, RTX 5070 Laptop GPU).
Metric Bonsai-27B-Q1_0 (Baseline) Ternary-Bonsai-2-9B-PTQ1_0 Bonsai-8B-Q1_0 Qwen3.5-4B-Q3_K_M Ternary-Bonsai-2-4B-PQ2_0
File size 3.54 GiB (3.80 GB) 1.86 GiB (2.00 GB) 1.08 GiB (1.16 GB) 2.14 GiB (2.29 GB) 1.07 GiB (1.15 GB)
Reasoning (6) 6/6 (100%) 5/6 (83.3%) 5/6 (83.3%) 5/6 (83.3%) 5/6 (83.3%)
Single-Turn Tools (6) 6/6 (100%) 6/6 (100%) 6/6 (100%) 6/6 (100%) 6/6 (100%)
Multi-Turn Tools (5) 5/5 (100%) 5/5 (100%) 5/5 (100%) 5/5 (100%) 5/5 (100%)
Core Math (4, no think) 3/4 (75.0%) 4/4 (100%) 4/4 (100%) 3/4 (75.0%) 2/4 (50.0%)
Core Coding (4, unit-tested) 4/4 (100%) 4/4 (100%) 4/4 (100%) 4/4 (100%) 4/4 (100%)
Overall (25) 24/25 (96.0%) 24/25 (96.0%) 24/25 (96.0%) 23/25 (92.0%) 22/25 (88.0%)
Avg speed (RTX 5070) 51.3 tok/s 78.4 tok/s 114.8 tok/s 78.6 tok/s 107.9 tok/s
Total eval time 418.3 s 288.8 s 62.9 s 304.7 s 159.3 s
Peak VRAM (ctx=16384) 4.35 GB 2.25 GB 2.32 GB 2.54 GB 1.54 GB

Deep Agentic Evaluation (Top 3 Compact Finalists)

The stateful multi-turn gauntlets separated genuine agentic reliability from single-turn fluency. While all three finalists scored 8 / 8 on Tool Abstention and swept Museum Heist and ARASAKA with zero errors, Verdant-9’s combined power-bounds, crew-filtering, and dynamic PIN calculation exposed a sharp split: Bonsai-8B-Q1_0 entered a 9-error syntax retry loop (5 / 10), whereas both Ternary-Bonsai-2-9B-PTQ1_0 and Qwen3.5-4B-Q3_K_M cleared every single gauntlet with zero errors—with Ternary-Bonsai-2-9B-PTQ1_0 finishing Verdant-9 in fewer turns (9 vs. 11) and less time (25.8 s vs. 32.2 s).

Grand total across all 5 deterministic suites (61 scored points)

Ternary-Bonsai-2-9B-PTQ1_0 (1.86 GiB)60 / 61 · 98.4%
Qwen3.5-4B-Q3_K_M (2.14 GiB)59 / 61 · 96.7%
Bonsai-8B-Q1_0 (1.08 GiB)55 / 61 · 90.2%
Deep agentic evaluation across the top 3 compact finalists (61 total points).
Benchmark Ternary-Bonsai-2-9B-PTQ1_0 (1.86 GiB) Qwen3.5-4B-Q3_K_M (2.14 GiB) Bonsai-8B-Q1_0 (1.08 GiB)
25-Eval Main Suite 24 / 25 (96.0%) 23 / 25 (92.0%) 24 / 25 (96.0%)
Tool Abstention (7 traps + control) 8 / 8 (100%) 8 / 8 (100%) 8 / 8 (100%)
Verdant-9 Gauntlet (10 milestones) 10 / 10 (9 turns, 0 err, 25.8 s) 10 / 10 (11 turns, 0 err, 32.2 s) 5 / 10 (14 turns, 9 err, looped)
Museum Heist Gauntlet (10 milestones) 10 / 10 (10 turns, 0 err, 29.1 s) 10 / 10 (11 turns, 0 err, 30.6 s) 10 / 10 (10 turns, 0 err, 4.74 s)
ARASAKA Gauntlet (8 milestones) 8 / 8 (9 turns, 0 err, 16.8 s) 8 / 8 (9 turns, 0 err, 15.9 s) 8 / 8 (9 turns, 0 err, 5.13 s)
Grand Total (61 points) 60 / 61 (98.4%) 59 / 61 (96.7%) 55 / 61 (90.2%)

Final model selection and deployment profile

Selected architecture: prism-ml/Ternary-Bonsai-2-9B-PTQ1_0.gguf (unmodified standalone).

No speculative drafting, no SSD sharding, and no vocabulary trimming are needed: the unmodified 1.86 GiB (2.00 GB) ternary 9B checkpoint achieves 60 / 61 (98.4%) while keeping its full 248,320-token multilingual and code vocabulary intact.

Notable runners-up

Key takeaways for on-device AI

Project O27 began by asking how much systems engineering is required to squeeze a 27B 1-bit model onto memory-starved hardware—and proved that lossless 214 MB SSD sharding, speculative drafting, and BPE merge-closed vocabulary trimming can cut RAM below 1 GB and reclaim 272.7 MiB with bit-identical accuracy. Yet the most important lesson came from testing those optimizations against newer sub-2-bit ternary architectures on unforgiving, stateful agentic benchmarks: a native 9B ternary model at 1.86 GiB now delivers 27B-class accuracy and error-free multi-turn tool use out of the box, with none of the latency or complexity of SSD streaming.

Read the companion retirement interviews for Orion’s earlier on-device foundations in Retirement Interview with Qwen 3.5 4B: Orion V3 through V6 and Commitments on Model Preservation and a Retirement Interview with Dolphin 3.0.