Instructions to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K # Run inference directly in the terminal: llama cli -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K # Run inference directly in the terminal: llama cli -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K # Run inference directly in the terminal: ./build/bin/llama cli -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Use Docker
docker model run hf.co/ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
- Llama new
- LM Studio
- Jan
- vLLM
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
- Ollama
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with Ollama:
ollama run hf.co/ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
- Unsloth Desktop
- Pi
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with Docker Model Runner:
docker model run hf.co/ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
- Lemonade
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Run and chat with the model
lemonade run user.DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q6_K
List all available models
lemonade list
- Hermes Agent
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp:Q6_K" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
DFlash2 draft for Ternary Bonsai 2.5 27B on stock llama.cpp
A DFlash2 draft model (Qwen3.8-27B backbone by Inco AI) adapted to draft for Ternary Bonsai 2.5 27B, bringing speculative decoding to the ternary target on unpatched llama.cpp while preserving the target's outputs.
Draft backbone: Qwen3.8-27B-DFlash2 by Inco AI (1.9B parameters) ยท Target: Ternary Bonsai 2.5 27B, Q2_0 by Prism ML ยท Runtime: stock llama.cpp (tested on b12345) ยท Build code and measurements: GitHub ยท Model page
The problem
Ternary Bonsai 2.5 27B is a Hadamard-latent model: llama.cpp loads its token embedding table rotated and every weight that reads the residual stream folded (prism.hadamard). The target restores the primal basis inside its own graph, right after the embedding lookup.
A DFlash2 draft has no embedding table and no output head of its own. It borrows both from the target and uses them as they are. On a Hadamard-latent target that means rotated embedding rows and a folded head, so every drafted token is rejected: acceptance is exactly 0 (0 of 5,932 tokens over 12 configurations), and decode drops from 56 to 23โ25 t/s because the target still pays for the useless drafts.
flowchart LR
subgraph target["Target graph (correct)"]
Z1["token_embd (rotated)"] -->|"get_rows"| R1["rotated row z"]
R1 -->|"H, then signs"| P1["primal embedding h"]
P1 --> L1["layers"] --> X1["residual x"]
X1 -->|"signs, then H"| X2["xโฒ"]
X2 --> W1["output (folded)"] --> LG1["logits"]
end
subgraph draft["Draft graph before this work (broken)"]
Z2["token_embd (rotated, borrowed)"] -->|"get_rows"| R2["rotated row z"]
R2 --> D1["draft layers"] --> X3["draft hidden x"]
X3 --> W2["output (folded, borrowed)"] --> LG2["garbage logits"]
end
subgraph fixed["Adapted draft (this repository)"]
E3["token_embd (primal, own)"] -->|"get_rows"| P3["primal row h"]
P3 --> D2["draft layers"] --> X4["draft hidden x"]
X4 --> W3["output (primal, own)"] --> LG3["logits"]
end
There are two independent gaps. Fixing only the embedding still yields zero acceptance (0 of 8,358 drafted tokens), because the borrowed head is folded.
What is in this repository
Three adapted draft cards. Each one is the original Q4_K_M DFlash2 draft body copied byte for byte, plus two tensors in the primal basis: token_embd.weight and output.weight (5120 ร 248,320). Both are optional tensors of the DFlash architecture, so llama.cpp uses them instead of borrowing. The variants differ only in how those two tables are quantized.
| File | Embedding table | Head table | Size | Window on a 16 GB GPU* |
|---|---|---|---|---|
DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q4_K_M-TQ4_K_Q6_K.gguf (recommended) |
Q4_K (682 MiB) | Q6_K (995 MiB) | 2.75 GiB | 185,600 |
DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q4_K_M-TQ8_0.gguf |
Q8_0 (1288 MiB) | Q8_0 (1278 MiB) | 3.63 GiB | 172,288 |
DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q4_K_M-TQ4_K.gguf |
Q4_K (682 MiB) | Q4_K (682 MiB) | 2.44 GiB | 199,936 |
* Context size chosen by the server's memory fitting with every layer of the target and the draft on the GPU, q4_0 KV cache. The bare target fits 262,144.
SHA-256:
b2a6bb8a3c8afde618f990aaa856654a840ac63a22f37db485cc28d8619fef82 ...-TQ4_K_Q6_K.gguf
ddad3dcdd8004a65a990e240f0177bf0c02363d4f16fcd6b36be37257d3370aa ...-TQ8_0.gguf
fc01b48102955fe63e1a61986783ea3c0a260707bd16b22e382ff604681cca5a ...-TQ4_K.gguf
Quick start
Requirements: stock llama.cpp with the Hadamard activation runtime (release b11556 or newer, which the Q2_0 target needs anyway) and DFlash2 draft support. Tested on b12345, CUDA 13.5, RTX 4070 Ti SUPER 16 GB.
Use the base target file, not the -mtp variant (the MTP head and an external draft are not meant to be combined).
huggingface-cli download ARRANCORE/DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp \
DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q4_K_M-TQ4_K_Q6_K.gguf --local-dir .
huggingface-cli download prism-ml/Ternary-Bonsai-2.5-27B-GGUF Ternary-Bonsai-2.5-27B-Q2_0.gguf --local-dir .
llama-server -m Ternary-Bonsai-2.5-27B-Q2_0.gguf \
--model-draft DFlash2-Ternary-Bonsai-2.5-27B-llama.cpp-Q4_K_M-TQ4_K_Q6_K.gguf \
--spec-type draft-dflash --spec-draft-n-max 4 --spec-draft-p-min 0 --spec-draft-n-cpu-moe 0 \
-fa on -b 1024 -np 1 -jinja --metrics \
-c 8192 -ctk q8_0 -ctv q8_0 \
--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --repeat-penalty 1.0 \
--host 127.0.0.1 --port 1234
For the largest window, drop -c and the q8 cache flags and add -ctk q4_0 -ctv q4_0 -ub 256 --spec-draft-n-ubatch 64; the server then picks the context that fits. Check the log (run with -lv 4) for offloaded 65/65 layers: with a window that does not fit, the server silently moves layers to the CPU and decode collapses.
Sampling follows the target's recommended thinking-mode chain (temperature 1.0, top_p 0.95, top_k 20, min_p 0). llama.cpp defaults to min_p 0.05; pass --min-p 0.
How it works
The target stores an embedding row rotated and restores it in its graph as h = signs โ (H z), where H is the normalized SylvesterโWalshโHadamard transform applied per block of 1024 along the last axis and signs is a ยฑ1 vector of the embedding width. The folded head obeys the same relation along its input axis: W_primal[i, v] = signs[i] ยท (H W_folded)[i, v]. Both relations were verified against the target: layer-0 inputs of 256 tokens match the unwrapped rows with cosine 1.000000, while the raw rows are orthogonal to them (โ0.0001).
flowchart LR
T["Target GGUF<br/>token_embd, output (rotated / folded)"] --> DQ["dequantize"]
M["prism.hadamard<br/>block size, sign vector"] --> U
DQ --> U["unwrap<br/>h = signs ยท (H z)"]
U --> Q["quantize tables<br/>Q8_0 / Q4_K / Q6_K"]
B["DFlash2 draft GGUF<br/>(body verbatim)"] --> A["assemble card"]
Q --> A
A --> V["validate<br/>body byte-identical, tables present"]
V --> LS["lossless check<br/>greedy output == bare target"]
Everything is offline. The target file is not modified.
Benchmarks
One workstation (RTX 4070 Ti SUPER 16 GB, Windows, llama.cpp b12345): the 8k benchmark in one night, six runs per variant in two server restarts; the depth ladders the next morning with the depth_bench tool from the build repository. Acceptance is the share of drafted tokens accepted; tau is the number of tokens emitted per verification round.
Decode at 8k context, temperature 1.0, n_max 4 (fixed coding prompt, 700 tokens, thinking on):
| Variant | Decode, t/s (6 runs) | Pooled | Median | tau | VRAM |
|---|---|---|---|---|---|
| Target alone | 55.8, 56.5, 56.8 | 56.4 | 56.5 | โ | 8.3 GiB |
| Embedding Q4_K + head Q6_K (recommended) | 59.6, 65.7, 73.8, 77.4, 65.9, 76.0 | 69.1 | 71.7 | 2.74โ3.70 | 12.1 GiB |
| Both Q8_0 | 64.7, 51.4, 65.3, 52.9, 84.1, 66.6 | 62.6 | 65.0 | 2.15โ3.70 | 12.3 GiB |
| Both Q4_K | 60.8, 52.0, 50.8, 57.4, 77.9, 49.7 | 56.7 | 55.1 | 2.16โ3.37 | 11.7 GiB |
| Original draft (not adapted) | โ | 23โ25 | โ | 1.00 | โ |
Decode versus context fill, measured with depth_bench from the build repository: the context is filled with boilerplate, then one prose and one coding probe are timed at each level. Three passes of the recommended card (two with English filler, one with Russian), each on a fresh server; target alone for reference. Values are t/s with tau in brackets; the three entries per cell are the three passes.
| Fill | Target alone, prose / code | Card, prose | Card, code | Card / target |
|---|---|---|---|---|
| ~8k | 52.9 / 53.0 | 45.5 (2.02) ยท 44.2 (1.96) ยท 50.9 (2.26) | 48.9 (2.19) ยท 50.5 (2.24) ยท 45.4 (2.01) | 0.90 |
| ~33k | 43.2 / 43.8 | 34.8 (1.82) ยท 39.7 (2.08) ยท 37.5 (1.95) | 36.5 (1.91) ยท 42.9 (2.25) ยท 45.5 (2.38) | 0.91 |
| ~66k | 36.5 / 37.5 | 35.6 (2.22) ยท 38.0 (2.37) ยท 34.9 (2.18) | 40.7 (2.54) ยท 46.2 (2.89) ยท 33.1 (2.06) | 1.03 |
| ~131k | 28.7 / 29.1 | 30.8 (2.50) ยท 30.3 (2.46) ยท 30.9 (2.51) | 33.9 (2.77) ยท 30.9 (2.51) ยท 33.6 (2.74) | 1.10 |
| ~183k | 24.1 / 24.2 | 23.6 (2.25) ยท 20.6 (1.94) ยท 21.0 (1.95) | 23.7 (2.27) ยท 33.7 (3.24) ยท 25.1 (2.36) | 1.02 |
Every needle was found at every level in every pass. What decides whether the draft pays is tau, not depth. On this pair a verification round costs about 2.3 single-token steps of the target, so the pair is faster than the target alone only when tau is above about 2.3, and the speed-up is close to tau / 2.3. In these boilerplate-filled ladders tau stayed between 1.8 and 2.4 over the first 32k tokens and the card was 10 % slower than the target (0.81โ1.04 per probe); further in tau moved to 1.9โ3.2 and the card was 2โ10 % faster on average (0.85โ1.39 per probe). The +22 % at 8k in the table above is the favorable case (tau 2.7โ3.7), not a lower bound.
Lossless: the draft never changes what the target computes. With greedy
decoding on five prompts (400 tokens each) the pair reproduced the bare
target's output exactly on four; on the fifth the two diverged once, 65 % into
the output, where the target picked modulo and the pair taking the remainder, two synonymous continuations of the same sentence. That is what
a near-tie looks like when the target scores several tokens per step
instead of one; the outputs are identical except on such near-ties.
Run-to-run spread is large (a single run moves between 50 and 84 t/s because the draft's luck with the sampled material varies, and tau at one context level moved between 1.9 and 3.2 from pass to pass), and all numbers come from one machine in one session. Treat the ordering as a strong hint, not as a settled result.
Limitations and gotchas
- The gain is not guaranteed: it depends on
tau. On this pair a verification round costs about 2.3 single-token steps of the target, so the draft is faster than the target alone only whentauis above about 2.3. In contexts filled with boilerplatetaustayed at 1.8โ2.4 over the first 32k tokens (card 10 % slower than the target at 8k and 32k) and moved to 1.9โ3.2 further in (2โ10 % faster on average). Measuretauin/metricson your own material. - The depth ladders are synthetic: repeated boilerplate as filler and one probe per level. Long real sessions were not measured.
n_max 7andp_min 0.2are slower thann_max 4withp_min 0on this pair (52.0 and 55.9 against 62.6 t/s for the Q8_0 variant).- A window that does not fit fails silently. Newer llama.cpp servers fit layers to free memory: check
offloaded 65/65 layersin the log. - The draft's embedding table lives in host memory (the target's tokenizer table does too); only the head occupies VRAM. That is why lighter heads buy both speed and window.
- Do not switch
enable_thinkingbetween requests of one conversation. The chat template changes from its first token, which costs a full re-prefill. - The first request after a server start is slower.
Acknowledgements
- Inco AI for DFlash 2 and the Qwen3.8-27B-DFlash2 draft this repository adapts (Apache 2.0), and Jian Chen, Yesheng Liang and Zhijian Liu for the original DFlash paper.
- Prism ML for Ternary Bonsai 2.5 27B, the prism.hadamard format and its llama.cpp runtime (PrismML-Eng). Created using Bonsai by Prism ML.
- Qwen (Alibaba Cloud) for Qwen3.8-27B, the common ancestor of the draft and the target.
- llama.cpp contributors for the runtime, gguf-py and llama-quantize, which encoded the Q4_K and Q6_K tables.
- Unsloth for the UD-Q4_K_M conversion the target's upstream MTP head derives from.
- Dogukan Urker for community measurements of Bonsai 2.5 with speculative decoding that informed the VRAM budget.
License
Apache 2.0. The draft body derives from incoai/Qwen3.8-27B-DFlash2 (Apache 2.0); the added tables are derived from prism-ml/Ternary-Bonsai-2.5-27B-GGUF (Apache 2.0, see its NOTICE.txt for upstream attribution). See NOTICE.txt in this repository.
- Downloads last month
- -
6-bit
8-bit