PrismML-Eng/Bonsai-demo
Quantized Bonsai LLMs for local inference with llama.cpp and MLX
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Bonsai-demo is a setup and launch layer for quantized model checkpoints, not an inference engine. setup.sh and setup.ps1 prepare the environment, fetch checkpoints from Hugging Face, and install a matching llama.cpp runtime. The scripts in scripts/ expose both one-shot CLI inference and a persistent local server. On Apple Silicon, the Bonsai 2 MLX path uses the native loader in mlx-vlm==0.7.8, with mlx-lm==0.32.0 pinned alongside it; the tested mlx-lm version does not load the current prism_hadamard_qwen35 checkpoints directly.
The Python project declares no packages of its own. Its Python 3.11–3.12 environment uses huggingface-hub, certifi, cmake, ninja, and setuptools for setup and build tooling. At the application boundary, the model returns structured OpenAI-style tool_calls; the client or UI runs the tool and passes the result back. The demo UIs support MCP, while the optional Open WebUI integration pins 0.10.2 for its tool-call iteration cap. The full UI stack is not required for CLI or server inference.
Key Capabilities & Differentiators
The default is Bonsai 2.5 27B; Bonsai 2 offers 2B, 4B, 9B, and 27B checkpoints in GGUF and MLX. The GGUF route covers Metal on Mac, CUDA/Vulkan/ROCm on supported Linux and Windows configurations, and CPU execution. Bonsai 2.5 retains vision, thinking, native tool calls, and a 262K-token context ceiling. Its MLX pack is text-only, so use llama.cpp for Bonsai 2.5 image input, or Bonsai 2 if vision must run on MLX.
On the PrismML llama.cpp path, the default Bonsai 2.5 download has a built-in multi-token-prediction (MTP) draft head. The runtime enables drafting automatically on CUDA-class GPUs and Metal; the reported NVIDIA gain is 1.5–1.8× in decoding, not end-to-end request latency. The 27B thinking profile defaults to xhigh; medium is the shorter option. Bonsai 2 2B/4B/9B use a distinct sampling profile with min_p=0 and a 64-token presence-penalty window, so clients should not copy the Bonsai 2 27B settings across sizes.
Trade-offs & Limitations
Choose stock llama.cpp b11556 or newer with official Q2_0 when upstream compatibility matters more than access to PrismML-specific formats and drafting. Older engines can recognize the format without implementing the required Hadamard transforms. The fork supports PTQ1_0 and PQ2_0; for Bonsai 2 27B, PQ2_0 trades about 1.3 GB of additional storage for faster prompt processing. A desktop frontend that imports GGUF is not necessarily compatible: it depends on the engine and loader it bundles.
Local inference removes the hosted model API dependency, but the operator still owns GPU memory, context sizing, and concurrency. Checkpoint and download sizes are not peak VRAM figures. Start with one request slot (-np 1) on a tight GPU budget, then measure with representative context lengths before increasing parallelism. BONSAI_CTX and optional 4-bit KV cache are separate memory controls; the 262K model ceiling is not a sensible default for every machine. The repo's Apache-2.0 license covers demo code; assess model and dependency terms separately.
Hardware & Deployment Guide
Use ./setup.sh on macOS/Linux or setup.ps1 on Windows. The shell setup uses uv and Python 3.11–3.12; it checks macOS Xcode Command Line Tools or Linux build prerequisites and fetches model files and pinned PrismML binaries (prism-b12220-41c86f7), with a source-build option. For Bonsai 2.5 27B, plan for about 7.6 GB for the PQ2_0 setup download on most backends, including the draft head and vision projector, or about 6.4 GB for the CUDA-class PTQ1_0 path. Open WebUI and the interpreter add several GB; set BONSAI_OPENWEBUI=0 and BONSAI_CODE_INTERPRETER=0 before setup to omit them.
After downloads, local inference runs without a hosted model API. Start ./scripts/start_llama_server.sh for the loopback service at http://localhost:8080, use ./scripts/run_llama.sh for a one-shot prompt, or use ./scripts/start_mlx_server.sh for the MLX server. Keep the default 127.0.0.1 binding unless remote access is intentional and protected. The concrete upstream compatibility milestone is llama.cpp b11556, which merged the model and Hadamard integration for Q2_0; it is not a release of Bonsai-demo itself.
BONSAI_MODEL selects Bonsai 2 at 2B, 4B, or 9B, and BONSAI_FAMILY=bonsai2 selects the earlier 27B.Q2_0 needs upstream llama.cpp b11556 or newer; PQ2_0, PTQ1_0, and built-in Bonsai 2.5 MTP use the PrismML fork.*-mtp.gguf build; drafting is enabled by default on CUDA-class GPUs and Metal and can be disabled with BONSAI_SPECULATIVE=0.BONSAI_CTX sets context length, BONSAI_KV4=1 enables a 4-bit KV cache, and -np 1 limits llama-server to one request slot.tool_calls; the demo UIs support MCP, and the optional Open WebUI integration is pinned to 0.10.2.Teams evaluating local text, image, or tool-calling workflows that want a CLI and a loopback API, with the option to start at 2B/4B/9B before sizing a 27B deployment.
You need a managed concurrency SLA, must use an older bundled engine, or require image input specifically from Bonsai 2.5 on MLX.
Quick Start & Installation
export BONSAI_MODEL=4B # 2B, 4B, or 9B (Bonsai 2); add BONSAI_FAMILY=bonsai2 for its 27B
./setup.sh
./scripts/start_llama_server.shAI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/PrismML-Eng/Bonsai-demo.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about Bonsai-demo
How should an application integrate with Bonsai?
thinking_budget, whereas llama-server uses thinking_budget_tokens.Does the smaller CUDA download mean Bonsai 2.5 fits in 8 GB of VRAM?
-np 1, including desktop usage. Treat that as one configuration, not a minimum or guarantee.Can we self-host or redistribute the stack commercially?
When is stock llama.cpp preferable to the demo's default runtime?
Q2_0 if you already maintain an upstream deployment and do not need PrismML's drafting path. Use the PrismML fork for PQ2_0, PTQ1_0, or the built-in Bonsai 2.5 MTP head. In a desktop app, verify the bundled engine and loader version; a GGUF import option by itself is not enough.Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy