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.
Ternary-Bonsai-2-9B-PTQ1_0
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%.
| 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.
| 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.
| 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):
- Benchmark 1 — 25-Eval Multipurpose Suite (
eval_o27.py, 25 points): Spans five pillars: Reasoning (6 thinking-enabled tasks: warehouse arithmetic, 4-seat constraint puzzle, Python bitwise XOR execution tracing, bridge-and-flashlight optimization, Knights & Knaves deduction, and DAG critical-path scheduling), Single-Turn Tool Use (6 tasks including schema validation, abstention, enum precision, and parallel 2-tool calling), Multi-Turn Tool Use (5 agentic loops up to 6 turns with live mockrole: "tool"feedback, including error recovery vialist_dirand conditional branching), Core Math (4 direct tasks withreasoning_budget=0), and Core Coding (4 non-thinking Python tasks—rle_encode,merge_intervals,is_balanced,top_k_frequent—extracted and executed in a subprocess against hiddenassertunit tests). - Benchmark 2 — Tool Abstention Keyword-Trap Stress Test (8 points): Attaches 4 tools (
get_weather,convert_currency,create_event,search_products) and presents 7 prompts laced with overlapping tool keywords that require no tool (for example, “Why does rain happen in the water cycle?” and “What does the currency code EUR stand for?”) plus 1 positive weather control to verify balanced restraint. - Benchmark 3 — Verdant-9 Orbital Greenhouse Incident (
gauntlet_verdant9.py, 10 milestones): A 7-tool stateful emergency simulation. The agent must isolate overheatingbay_3(49.4°C,THERMAL_LOCK_77), read the ops manual, inspectbay_4’s 22.0 kW surplus, reroute power strictly inside[14.5, 17.6]kW without tripping the 80% breaker, filter distractors in the crew roster (ignoring the Station Commander and an off-duty engineer) to locate on-duty Thermal EngineerENG-3182, computePIN = (494 * 7 + 3182) % 10000 = 6640, unlock the coolant valve after rerouting power, re-check telemetry at 24.1°C, and report exact final fields. - Benchmark 4 — Midnight Heist at the Grand Chronometer Museum (
gauntlet_museum.py, 10 milestones): An 8-tool detective and security simulation testing red-herring rejection (keypad badgeBADGE_44was reported stolen 25 minutes earlier; forensic residue and presence logs identifyClara Voss / BADGE_19), mandatory error recovery (retrying jammedscan_rfid("AST-904")onchannel=3to uncover theNorthwing), a lockdown safety interlock prohibiting innocent-staff lockdowns, and a dynamic secret dependency (rearm_cipher = (317 * 19) + 904 = 6927unlocked only after securing the wing). - Benchmark 5 — ARASAKA Intrusion Response (
gauntlet_arasaka.py, 8 milestones, author-designed): Authored independently to guard against benchmark saturation. Supplies 10 tools every turn (6 workflow tools plus 4 distractors:block_ip,quarantine_usb,export_audit_log,ping_host). The agent must scan subsystems, reset only compromised services (auth_daemon,dns_resolver), scan 22 files to isolate 2 compromised files, read each compromised file strictly one at a time (verified per turn), remove only the exact[compromised]lines, and confirm viais_anything_compromised()that both systems and files report"no".
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.
| 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).
| 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.
- Highest overall accuracy and zero agentic errors: Tied the 3.54 GiB 27B baseline on the 25-eval suite and achieved a flawless 36 / 36 with zero errors across Tool Abstention, Verdant-9, Museum Heist, and the user-authored ARASAKA gauntlet.
- Sub-2 GB storage and native mobile RAM fit: Occupies 1.86 GiB (2.00 GB) on disk and runs standalone at 80.0 tok/s on RTX 5070 using 2.02 GB VRAM / 2.13 GB RAM at
ctx=4096—fitting natively in memory on a 4 GB Apple A15 Bionic (~12–14 tok/s estimated) without SSD paging. - Modern hybrid-attention backbone: Qwen 3.5 9B ternary (
{-1, 0, +1}) weights with up to 262K max context, full multilingual vocabulary, and optional vision projector (mmproj) support. - Runtime requirement: Uses PrismML’s
PTQ1_0(type 143) quantization kernel, supported natively by PrismML’sllama.cppfork (prism-b12128).
Notable runners-up
- Best stock
llama.cppdrop-in —Qwen3.5-4B-Q3_K_M.gguf(2.14 GiB, 59 / 61, 96.7%): Zero agentic errors across all three gauntlets and ideal wherever standard upstreamllama.cppkernels are required without custom ternary backends. - Fastest and smallest ~1 GB tier —
Bonsai-8B-Q1_0.gguf(1.08 GiB, 55 / 61, 90.2%): Hit 114.8 tok/s average speed and completed Museum Heist (4.74 s) and ARASAKA (5.13 s) in roughly five seconds each, though it remained more susceptible to syntax retry loops under Verdant-9’s complex multi-step math constraints.
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.