Text Generation
GGUF
English
Japanese
ternary
ptq1_0
pq2_0
q2_0
2-bit
qsa
sparse-attention
long-context
256k
llama-cpp
cuda
mtp
speculative-decoding
agentic
tool-calling
bonsai
qwen35
conversational
Instructions to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF 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 sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF 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 sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0 # Run inference directly in the terminal: llama cli -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0 # Run inference directly in the terminal: llama cli -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
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 sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
Use Docker
docker model run hf.co/sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
- Ollama
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with Ollama:
ollama run hf.co/sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
- Unsloth Desktop
- Pi
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
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": "sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with Docker Model Runner:
docker model run hf.co/sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
- Lemonade
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
Run and chat with the model
lemonade run user.Ternary-Bonsai-2.5-27B-QSA-GGUF-Q2_0
List all available models
lemonade list
- Hermes Agent
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
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 sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0
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 "sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF:Q2_0" \ --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"
Upgrade model card with publication figures, hardware/sampling guides, and Japanese README
Browse filesFiles changed (8)
- .gitattributes+3
- README.ja.mdAdded+275
- README.md+222-80
- SHA256SUMS+6-2
- assets/architecture.pngAdded
- assets/quality-benchmarks.pngAdded
- assets/throughput-vram.pngAdded
- release-manifest.json+22-2
33 unmodified lines34353633 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textTernary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf filter=lfs diff=lfs merge=lfs -text33 unmodified lines34353637383933 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textTernary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf filter=lfs diff=lfs merge=lfs -textassets/architecture.png filter=lfs diff=lfs merge=lfs -textassets/quality-benchmarks.png filter=lfs diff=lfs merge=lfs -textassets/throughput-vram.png filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275# Ternary-Bonsai-2.5-27B-QSA (GGUF)
[English](README.md) | **日本語**
[](https://arxiv.org/abs/2608.30320)[](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF)[](#モデル仕様)[](#ハードウェアと-vram-の目安)[](LICENSE)
`Ternary-Bonsai-2.5-27B-QSA` は、PrismML が公開している 1.75 bpw 三値量子化モデル [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF)(内蔵 `blk.64` Multi-Token Prediction ドラフトヘッドを含む全 866 テンソルを無変換コピー)に、Bonsai-2.5 自身の `PTQ1_0` 密アテンション分布で蒸留した FP32 Qwen Sparse Attention(QSA)インデクサー 80 テンソルを統合した **6.14 GiB** の GGUF モデルです。対応する `llama.cpp` CUDA/CPU パッチを同梱しています。
> [!IMPORTANT]> **実行エンジンの要件**: 素の `llama.cpp` では QSA GGUF を実行できません。`PrismML-Eng/llama.cpp`(`prism` ブランチ)に [`patches/bonsai-qsa-engine.patch`](patches/bonsai-qsa-engine.patch) を適用してビルドしてください。パッチにより、Hadamard 回転付き `F16` / `Q8_0` KV キャッシュに対応するゼロマスク・ブロック疎 CUDA カーネル `qsa-attn.cu` と、同一 GGUF のまま Dense 推論へ切り替える環境変数 `LLAMA_QSA_DENSE=1` が有効になります。

## 主な特徴
- 単一 24 GB GPU(NVIDIA A10G)で **256K 文脈(262,144 トークン)を 15.85 GiB VRAM(16,227 MiB)** で実行でき、単一 16 GB GPU(Tesla T4)でも **192K 文脈(196,608 トークン)を 13.23 GiB VRAM(13,551 MiB)** で実行できます(`-ctk q8_0 -ctv q8_0 -fa on -np 1`)。- 長文デコードでは、Tesla T4 の 128K で Dense 比 **4.32 倍**(`5.37 -> 23.18 tok/s`、プリフィル `1.55 倍`)、NVIDIA A10G の 256K で **2.36 倍**(`18.64 -> 44.06 tok/s`、プリフィル `1.55 倍`)の速度を記録しました。8K から 64K の領域では内蔵の `blk.64` MTP ヘッド(`--spec-type draft-mtp --spec-draft-n-max 2`)によりデコード速度をさらに **+50% から +68%** 高められます。- 80 テンソルの FP32 QSA インデクサー(`bonsai25-qsa-indexers.safetensors`)は `higa2515` v2 を初期値として `Ternary-Bonsai-2.5-27B-PTQ1_0` の密アテンション分布から直接蒸留しています。全 16 層の検証 KL ダイバージェンスを **19.3%** 削減し(`0.4102 -> 0.3309`、最も乖離していた Layer 59 では **40.5%** 削減の `0.8382 -> 0.4987`)、比較したインデクサーの中で長文パープレキシティの悪化幅が最小となりました(64K 英語 PG-19 で `+1.155%`、32K 日本語 Wikipedia で `+0.741%`、32K Python コードで `+0.126%`)。- 64K(`8/8`)、128K(`5/5`)、256K(`5/5`)のデコイ付きニードル検索、語彙重複ゼロの NoLiMa 言い換え QA(64K / 128K ともに `8/8`)、日本語 64K 4 ターン制約保持(`8/8`)で **100%** を達成しました。8K の一般 62 問(GSM8K 30 問、Python 実行テスト 20 問、OpenAI `tool_calls` 12 問)では Dense との一致率が **98.4% から 100.0%** でした。一方、128K `recall-grid`(240 問、thinking off)では Dense `225/240`(93.75%)に対して `201/240`(83.75%)となり、高速化と引き換えの精度差が残ります。
---
## モデル仕様
| 項目 | 値 ||---|---|| ベースモデル | [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF)(`Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf`、`Qwen/Qwen3.8-27B` 派生) || アーキテクチャ | 64 層ハイブリッド(Gated DeltaNet 48 層 + QSA フルアテンション 16 層:`3, 7, ..., 63`)+ `blk.64` MTP ドラフトヘッド || 重み形式 | 1.75 bpw 三値 `PTQ1_0`(ベース 866 テンソルを無変換コピー)+ FP32 QSA インデクサー 80 テンソル(`52,434,944` パラメータ、200 MiB) || GGUF ファイルサイズ | **6.14 GiB**(`6,442,564,320` バイト、全 946 テンソル) || QSA スパース設定 | `block_size = 4`、`top_k = 2048`(上位 512 ブロック + 自ブロックで最大 2,052 トークンを参照)、4 Q-head / 1 K-head、`head_dim = 128`、`rope_dim = 64` || 検証済み最大文脈長 | 単一 24 GB GPU で **262,144 トークン(256K)** まで動作確認済み || エンジンパッチ | `PrismML-Eng/llama.cpp`(`prism` ブランチ)向け `patches/bonsai-qsa-engine.patch` || ライセンス | Apache-2.0(モデル重み、インデクサー、スクリプト、ドキュメント)、MIT(`patches/bonsai-qsa-engine.patch`) |
---
## ハードウェアと VRAM の目安
単一 GPU(`-ngl 999 -fa on -np 1 -b 512 -ub 512`)での実測値と目安です。48 層の Gated DeltaNet は状態量が `O(1)` で一定のため、文脈長に応じて KV キャッシュが増えるのは 16 層のフルアテンション層に限られます。さらに `qsa-attn.cu` は `[n_kv, n_tokens]` の密マスクバッファを確保しません。
| GPU クラス | 実用文脈長 | KV キャッシュ | 実測ピーク VRAM | MTP の推奨設定 | 実測デコード速度(`tok/s`) ||---|---:|---|---:|---|---:|| 12 GB GPU(RTX 3060 / 4070 等) | 64K から 96K | `q8_0` | 約 8.6 から 9.9 GiB(目安) | 64K 以下で `--spec-type draft-mtp --spec-draft-n-max 2` | メモリ帯域に応じて変動 || 16 GB GPU(Tesla T4、`sm_75`) | **128K から 192K** | `q8_0` | **10.77 GiB**(128K) / **13.23 GiB**(192K) | 8K から 64K で有効化(`36.6` から `44.3 tok/s`) | **23.18**(128K) / **21.51**(192K) || 24 GB GPU(A10G / RTX 3090 / 4090) | **256K** | `q8_0` | **15.85 GiB**(256K) | 8K から 128K で有効化(`50.4` から `86.5 tok/s`)、256K では無効推奨 | **44.06**(A10G・256K) || 48 GB GPU(L40S / A6000) | **256K** | `q8_0` または `f16` | **16.04 GiB**(256K・`q8_0`) | 256K で併用時は `--spec-draft-window` を指定 | **58.09**(256K・プリフィル `2,224`) |
---
## クイックスタート
### 1. ダウンロードと SHA-256 検証
```bashhf download sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF \ Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \ patches/bonsai-qsa-engine.patch \ SHA256SUMS \ --local-dir ./bonsai-2.5-qsa
( cd ./bonsai-2.5-qsa && grep -E ' (Ternary-Bonsai-2\.5-27B-PTQ1_0-QSA-bonsai-v1-mtp\.gguf|patches/bonsai-qsa-engine\.patch)$' SHA256SUMS | sha256sum -c -)```
### 2. パッチ適用済みエンジンのビルド(CUDA / CPU)
ビルドには CMake 3.20 以上、Ninja、Python 3.10 以上が必要です。GPU 推論を使う場合は CUDA Toolkit 12 以上も用意してください(CPU のみでビルドする場合は `-DGGML_CUDA=ON` を外します)。
```bashcd ./bonsai-2.5-qsagit clone --depth 1 -b prism https://github.com/PrismML-Eng/llama.cpp.git bonsai-qsa-enginegit -C bonsai-qsa-engine apply "$PWD/patches/bonsai-qsa-engine.patch"
cmake -G Ninja -S bonsai-qsa-engine -B bonsai-qsa-engine/build-cuda \ -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON \ -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF -DLLAMA_BUILD_TESTS=OFF
cmake --build bonsai-qsa-engine/build-cuda --target llama-cli llama-server llama-perplexity -j "$(nproc)"```
### 3. サーバー起動と疎通テスト
```bash# 単一 24 GB GPU:256K フル文脈(約 15.85 GiB VRAM)./bonsai-qsa-engine/build-cuda/bin/llama-server \ -m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \ -ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 262144 -np 1 -b 512 -ub 512 \ --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --presence-penalty 0.0 --repeat-penalty 1.0
# 単一 16 GB GPU:64K 文脈 + 内蔵 MTP 投機デコード(デコード +50% から +68%)./bonsai-qsa-engine/build-cuda/bin/llama-server \ -m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \ -ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 65536 -np 1 -b 512 -ub 512 \ --spec-type draft-mtp --spec-draft-n-max 2 \ --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --presence-penalty 0.0 --repeat-penalty 1.0
# 同一 GGUF のまま Dense フルアテンションへ切り替えて A/B 比較する場合LLAMA_QSA_DENSE=1 ./bonsai-qsa-engine/build-cuda/bin/llama-server ...```
OpenAI 互換 API の動作確認例です。
```bashcurl -s http://127.0.0.1:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "Ternary-Bonsai-2.5-27B-QSA", "messages": [{"role": "user", "content": "ブロック疎アテンションが長文デコードを高速化する理由を2文で説明してください。"}], "temperature": 0.7, "top_p": 0.8, "top_k": 20, "min_p": 0.0, "presence_penalty": 1.5, "max_tokens": 256 }'```
<details><summary>任意:PrismML のベース GGUF とインデクサーから手元で GGUF を再構成する手順</summary>
```bashpython3 scripts/bonsai_qsa_graft.py \ Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf \ bonsai25-qsa-indexers.safetensors \ Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf```
`scripts/bonsai_qsa_graft.py` は Python 標準ライブラリのみで動作し、ベースモデルの 866 テンソルを再量子化せずにそのままコピーします。
</details>
---
## 推奨サンプリング設定
上流の `prism-ml/Ternary-Bonsai-2.5-27B-GGUF` ��よび `Qwen/Qwen3.8-27B` の推奨値に沿った設定です。
| モード | `temperature` | `top_p` | `top_k` | `min_p` | `presence_penalty` | `repetition_penalty` ||---|---:|---:|---:|---:|---:|---:|| **Thinking モード**(既定の推論モード) | `1.0` | `0.95` | `20` | **`0.0`** | `0.0` | `1.0` || **Non-thinking / Instruct モード** | `0.7` | `0.80` | `20` | **`0.0`** | `1.5` | `1.0` || **決定論評価(ベンチマーク)** | `0.0` | `1.0` | `1` | `0.0` | `0.0` | `1.0` |
> [!TIP]> `llama.cpp` では既定値が `--min-p 0.05` のため、必ず `--min-p 0` を明示してください。`min_p` が非ゼロのまま残ると、長い推論過程で途中で出力が途切れる場合があります。
---
## ベンチマーク結果
以下の品質比較はすべて、**同一の `Ternary-Bonsai-2.5-27B-PTQ1_0` バックボーン**、同一バイナリ、同一 `Q8_0` KV キャッシュ(`-fa on -ctk q8_0 -ctv q8_0`)、同一 Greedy 設定(`temperature=0.0, top_k=1`)、同一 GPU で計測しています。条件差は 80 テンソルの FP32 QSA インデクサーまたは `LLAMA_QSA_DENSE=1` のみです。

### 1. スループットとピーク VRAM(単一 GPU、8K から 256K)
| GPU | 構成 | 文脈長(`-c`) | プロンプト長 | プリフィル(`tok/s`) | デコード(`tok/s`) | ピーク VRAM(`MiB`) ||---|---|---:|---:|---:|---:|---:|| Tesla T4 (16 GB) | Dense(`F16` KV) | 8,192 | 5,834 | 310.54 | 30.05 | 6,667 || Tesla T4 (16 GB) | QSA(`F16` KV) | 8,192 | 5,834 | 298.72 | 27.49 | 6,675 || Tesla T4 (16 GB) | QSA(`F16` KV)+ MTP | 8,192 | 5,834 | 287.82 | **44.31** | 7,351 || Tesla T4 (16 GB) | QSA(`Q8_0` KV、blk-kernel) | 65,536 | 55,886 | 221.71 | 24.50 | 8,555 || Tesla T4 (16 GB) | QSA(`Q8_0` KV)+ MTP | 65,536 | 55,886 | 213.26 | **36.63** | 9,457 || Tesla T4 (16 GB) | Dense(`Q8_0` KV) | 131,072 | 117,806 | 138.58 | 5.37 | 11,109 || Tesla T4 (16 GB) | QSA(`Q8_0` KV、blk-kernel) | 131,072 | 117,806 | **214.49** | **23.18** | **11,031** || Tesla T4 (16 GB) | QSA(`Q8_0` KV、blk-kernel) | 196,608 | 179,898 | 208.82 | 21.51 | 13,551 || NVIDIA A10G (24 GB) | Dense(`F16` KV) | 8,192 | 5,831 | 1,109.30 | 58.71 | 6,839 || NVIDIA A10G (24 GB) | QSA(`F16` KV) | 8,192 | 5,831 | 1,084.22 | 51.49 | 6,847 || NVIDIA A10G (24 GB) | QSA(`F16` KV)+ MTP | 8,192 | 5,831 | 1,014.78 | **86.47** | 7,523 || NVIDIA A10G (24 GB) | Dense(`Q8_0` KV) | 131,072 | 117,803 | 752.32 | 30.08 | 11,281 || NVIDIA A10G (24 GB) | QSA(`Q8_0` KV、blk-kernel) | 131,072 | 117,803 | **885.56** | **48.43** | **11,203** || NVIDIA A10G (24 GB) | QSA(`Q8_0` KV)+ MTP | 131,072 | 117,803 | 833.23 | 50.41 | 12,425 || NVIDIA A10G (24 GB) | Dense(`Q8_0` KV) | 262,144 | 239,923 | 543.05 | 18.64 | 16,305 || NVIDIA A10G (24 GB) | QSA(`Q8_0` KV、blk-kernel) | 262,144 | 239,923 | **841.19** | **44.06** | **16,227** || NVIDIA L40S (48 GB) | QSA(`Q8_0` KV、blk-kernel) | 262,144 | 239,923 | **2,224.38** | **58.09** | 16,430 |
*256K での MTP に関する補足*: 256K(`262,144`)では、内蔵の `blk.64` MTP ヘッドが `--spec-draft-window` を指定しない限り全 KV を密に参照します。そのため A10G の 256K では MTP なしの QSA の方が高速かつ省 VRAM です(`44.06 tok/s`・`16,227 MiB` に対し、無制限 MTP 併用時は `37.65 tok/s`・`18,089 MiB`)。
### 2. 高難度 128K 構造化検索(`recall-grid` 128K、全 240 問)
`recall_grid.py`(`seed=20261202`、ホールドアウトの `emozilla/pg19` 検証セット 50 冊、`doc_tokens=[127123, 127104]`、8 タスク x 10 深度 x 3 = **240 問**、15% 背景ノイズレコード、1 文字違いのハードネガティブ付き、`thinking off`、`max_tokens=1024`、NVIDIA L40S)で計測した結果です。
| アーム | 正答数 | 正答率 | `guid` | `pointer` | `ingredients` | `quantities` | `revision` | `join` | `code` | `binding` | 打切り ||---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|| **Dense(上限参照)** | **225/240** | **93.75%** | 29/30 | 27/30 | 30/30 | 25/30 | 27/30 | 30/30 | 30/30 | 27/30 | 3 || `higa2515-v2`(ゼロショット移植) | 202/240 | 84.17% | 26/30 | 26/30 | 27/30 | 21/30 | 23/30 | 28/30 | 26/30 | 25/30 | 11 || **`Bonsai-2.5 distilled v1`(本リリース)** | **201/240** | **83.75%** | 26/30 | 24/30 | 27/30 | 21/30 | 24/30 | 28/30 | 27/30 | 24/30 | 10 |
- 対応のある正確両側 McNemar 検定では、`bonsai25_v1` と `higa2515_v2` の不一致は `6` 対 `7`(`p = 1.0`)で統計的有意差はありません。Dense に対しては `bonsai25_v1` が `4` 対 `28`(`p = 1.9e-5`)、`higa2515_v2` が `7` 対 `30`(`p = 0.000191`)です。- 10 深度 x 8 タスクのヒートマップと誤答例は [`benchmarks/recall_grid_128k.html`](benchmarks/recall_grid_128k.html) に収録して��ます。
### 3. 長文言語モデリング・パープレキシティ(`llama-perplexity`)
厳密に分離したホールドアウトコーパス(`emozilla/pg19` `test`、`wikimedia/wikipedia` `20231101.ja` の 1,200 行目以降、Python 標準ライブラリ)を NVIDIA L40S・`Q8_0` KV キャッシュ(`-fa on -ctk q8_0 -ctv q8_0`)で計測しました。
| コーパスと文脈幅 | 疎化率 | Dense(`PPL ± SE`) | `Bonsai-2.5 v1`(`Δ%`) | `higa2515-v2`(`Δ%`) | `pentacoxian-255k`(`Δ%`) ||---|---:|---:|---:|---:|---:|| 英語 PG-19(`8K`、4 チャンク) | 約 50% | `9.5160 ± 0.2106` | **`9.4951`**(`-0.220%`) | `9.4950`(`-0.221%`) | `9.4971`(`-0.199%`) || **英語 PG-19(`64K`、32K-64K 末尾)** | **93.8-96.9%** | `11.7533 ± 0.1891` | **`11.8891`(`+1.155%`)** | `11.9029`(`+1.273%`) | `11.9061`(`+1.300%`) || 日本語 Wikipedia(`8K`、4 チャンク) | 約 50% | `12.0398 ± 0.2683` | `12.0319`(`-0.066%`) | `12.0283`(`-0.096%`) | `12.0305`(`-0.077%`) || **日本語 Wikipedia(`32K`、16K-32K 末尾)** | **87.5-93.8%** | `11.9643 ± 0.2621` | **`12.0530`(`+0.741%`)** | `12.0596`(`+0.797%`) | `12.0676`(`+0.863%`) || Python 標準ライブラリ(`32K`、16K-32K 末尾) | 87.5-93.8% | `1.7518 ± 0.0213` | `1.7540`(`+0.126%`) | `1.7539`(`+0.120%`) | `1.7535`(`+0.097%`) |
### 4. 忘却耐性・言い換え QA・マルチターン・256K ニードル試験
| 試験スイート | 文脈長 | `Dense` | `Bonsai-2.5 v1` | `higa2515-v2` | `pentacoxian-255k` ||---|---:|---:|---:|---:|---:|| デコイ付きニードル検索(1 文字違い偽キー) | 64K(8 深度) | 8/8 (100%) | **8/8 (100%)** | 8/8 (100%) | 8/8 (100%) || デコイ付きニードル検索(1 文字違い偽キー) | 128K(5 深度) | 1/1(単発確認) | **5/5 (100%)** | 5/5 (100%) | 5/5 (100%) || デコイ付きニードル検索(`240K`、疎化率 99.15%) | **256K**(5 深度) | 1/1(単発確認) | **5/5 (100%)** | 5/5 (100%) | 5/5 (100%) || NoLiMa 意味言い換え QA(語彙重複ゼロ) | 64K / 128K | 8/8 / 8/8* | **8/8 / 8/8** | 8/8 / 8/8 | 8/8 / 8/8 || 複数回更新・初期記憶(`v1` 初期値) | 64K / 128K | 8/8 / 8/8 | **8/8 / 8/8** | 8/8 / 8/8 | 8/8 / 8/8 || 複数回更新・最新状態(`v3` 最終上書き値) | 64K / 128K | 8/8 / 8/8 | 8/8 / 7/8 | 8/8 / 7/8 | **8/8 / 8/8** || 日本語長文 QA(8 深度、Wikipedia-ja) | 64K | 8/8 (100%) | **8/8 (100%)** | 8/8 (100%) | 8/8 (100%) || 日本語 4 ターン制約保持 + 1 ターン目秘密記憶 | 64K(4 ターン) | 8/8 (100%) | **8/8 (100%)** | 8/8 (100%) | 8/8 (100%) |
*\*Dense は 64K・128K 各 1 問で期待値 `"fused-silica"` に対してハイフンなしの `"Fused silica"` を出力しました(厳密文字列一致は `7/8`、意味正答は `8/8`)。*
### 5. 一般能力の一致率(`Dense` vs `QSA` vs `QSA + MTP`)
`ctx=8192`(`Q8_0` KV、`thinking off`、Greedy、NVIDIA L40S)で計測した結果です。
| 構成 | GSM8K(`test[:30]`) | Python 実行(20 テスト) | OpenAI `tool_calls`(日英 12 問) | 合計(62 問) | Dense との一致率 ||---|---:|---:|---:|---:|---:|| `Dense`(`LLAMA_QSA_DENSE=1`) | 25/30 (83.3%) | 19/20 (95.0%) | 12/12 (100%) | 56/62 (90.3%) | 基準 || **`Bonsai-2.5 distilled v1`(QSA)** | **26/30 (86.7%)** | **19/20 (95.0%)** | **12/12 (100%)** | **57/62 (91.9%)** | **61/62 (98.4%)** || **`Bonsai-2.5 distilled v1`(QSA + MTP)** | **25/30 (83.3%)** | **19/20 (95.0%)** | **12/12 (100%)** | **56/62 (90.3%)** | **62/62 (100.0%)** |
### 6. Bonsai-2.5 向けインデクサー蒸留結果(`v2` 初期値 -> `bonsai25-v1`)
`Ternary-Bonsai-2.5-27B-PTQ1_0` から `libqsacap.so` で直接取得した密アテンション分布を教師として、KL + 上位 128 制限 KL + デコイマージン損失で 50 ステップ蒸留しました(`seq_len=12,288`、`lr=5e-5 -> 5e-6`、`AdamW`、NVIDIA L40S 1 基、ピーク学習 VRAM `2.60 GiB`、所要時間 `33.9 分`)。
| 評価指標(ホールドアウト 8 系列、`seq_len=12,288`) | `higa2515-v2` ゼロショット | `Bonsai-2.5 distilled v1` | 変化 ||---|---:|---:|---:|| 全 16 層平均の検証 KL | `0.41017` | **`0.33094`** | **-19.3%** || 最大乖離層の KL(Layer 59) | `0.83821` | **`0.49865`** | **-40.5%** || Layer 55 / Layer 51 / Layer 63 の KL | `0.635 / 0.505 / 0.508` | **`0.404 / 0.373 / 0.404`** | **-36.4% / -26.1% / -20.4%** || 単層スコアの正解 > デコイ勝率 | `43.43%` | **`49.06%`** | **+5.62 pt** || 上位 64 / 上位 512 ブロックの正解再現率 | `93.05%` / `99.93%` | **`93.40%` / `99.96%`** | **+0.35 pt / +0.02 pt** |
---
## アーキテクチャと Hadamard 変換の整合性

`Ternary-Bonsai-2.5-27B` では、正規化 Sylvester Walsh-Hadamard 回転(`prism.hadamard.axis = input-last-dimension`)が `prism.hadamard.weight_names` に列挙された 401 個の三値線形層にのみ適用され、`token_embd.weight` に逆変換が保持されています。その結果、残差ストリームと `attn_norm` の出力は `Qwen3.8-27B` 元の非回転基底のまま保たれます。
1. 16 個の QSA インデクサー(フルアテンション層 `3, 7, ..., 63`、4 トークン平均プーリング、`top_k=2048` = 512 ブロック + 自ブロック)は、追加の Hadamard 変換を行わずに `attn_norm` をそのまま入力として受け取ります。2. `-ctk q8_0 -ctv q8_0` により KV キャッシュの Hadamard 回転(`self_k_rot` / `self_v_rot`)が有効な場合、`qsa-attn.cu` はインデクサーが選択した回転済み Q/K ブロック上で内積を計算し、出力側で `llama_mul_mat_hadamard(ctx0, cur, inp->self_v_rot)` により逆回転を戻します。3. 疎アテンション実行時に `[n_kv, n_tokens]` の密マスクバッファを確保しないため、256K(`262,144`)文脈でもピーク VRAM は `16,227 MiB` に収まります。
---
## 既知の制限と対象範囲
- Stage 1 のインデクサー蒸留のみを実施しています。1.75 bpw 三値バックボーンと `blk.64` MTP ヘッドは変更せずに固定しており、Stage 2 の疎アテンション向けバックボーン再適応は行っていません。- `thinking off` 条件の 128K `recall-grid` では Dense との間に統計的有意差が残ります(`201/240` 対 `225/240`、`p = 1.9e-5`)。主な要因は `K=2,048` が 128K 文脈の `1.6%` のみを参照する条件下での複数レコード集計(`quantities` / `ingredients`)、多段参照(`pointer`)、および `null` 判定の難しさです。今回の `v1` は 12K・50 ステップの蒸留であるため、128K `recall-grid` 正答率は `higa2515-v2` と同等(`201` 対 `202`、`p = 1.0`)ながら、長文 PPL(64K 英語 `+1.155%` 対 `+1.273%`、32K 日本語 `+0.741%` 対 `+0.797%`)と後半層の KL(Layer 59 で `-40.5%`)を改善しています。- 256K 文脈では MTP をオフにするか `--spec-draft-window` でドラフト側の参照範囲を制限してください。無制限 MTP は 8K から 128K の利用を推奨します。- 動作確認は Linux x86_64 CPU および単一 NVIDIA GPU(`sm_75`、`sm_86`、`sm_89`)のテキスト推論に限られます。ビジョン用 `mmproj` とマルチ GPU 分割は未検証です。
---
## ライセンスと出典
- モデル重み、蒸留済み QSA インデクサー、移植スクリプト、ドキュメント:Apache-2.0([`LICENSE`](LICENSE))- `patches/bonsai-qsa-engine.patch`:MIT(`PrismML-Eng/llama.cpp` 派生)- 上流プロジェクトの帰属表示と SHA-256 来歴は [`NOTICE.md`](NOTICE.md) および [`release-manifest.json`](release-manifest.json) を参照してください。29 unmodified lines30313233343536373839404142434445464748495051525354555657585960616263646566678 unmodified lines7677787980818283847 unmodified lines92939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291 unmodified line1311321331341351361371381391401411421431441451461471481491501511521531541551561571 unmodified line1591601611621631641651661671681691701711721731741751761771781793 unmodified lines18318418518618718818912 unmodified lines2022032042052062072082092102112122132142152163 unmodified lines22022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725829 unmodified lines# Ternary-Bonsai-2.5-27B-QSA (GGUF)**6.14 GiB** · **1.75 bpw Ternary (`PTQ1_0`) + Built-in MTP Head + Distilled Qwen Sparse Attention (QSA)** · **Up to 256K Context in 15.85 GiB VRAM**`Ternary-Bonsai-2.5-27B-QSA` integrates PrismML's 1.75 bpw ternary model [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF) (866 tensors verbatim, including its bundled `blk.64` Multi-Token Prediction draft head) with **Qwen Sparse Attention (QSA)** ([arXiv:2608.30320](https://arxiv.org/abs/2608.30320)) in a single **6.14 GiB GGUF** and patched `llama.cpp` CUDA/CPU engine.> [!IMPORTANT]> **Community adaptation & engine requirement**: Neither PrismML's `Ternary-Bonsai-2.5-27B` nor upstream `Qwen3.8-27B` ships with QSA enabled. Stock `llama.cpp` cannot execute QSA GGUFs; apply `patches/bonsai-qsa-engine.patch` to `PrismML-Eng/llama.cpp` (`prism` branch) to enable the `qsa-attn.cu` zero-mask block-sparse CUDA kernel (`F16` and `Q8_0` KV cache with Hadamard rotation) and `LLAMA_QSA_DENSE=1` dense comparison toggle.## Highlights- **256K context (`262,144` tokens) in 15.85 GiB VRAM (`16,227 MiB`)** on a single 24 GB GPU (and **192K context in 13.23 GiB VRAM** on a single 16 GB Tesla T4) using `-ctk q8_0 -ctv q8_0 -fa on`.- **Up to 4.32x faster decode at 128K** on Tesla T4 (`5.37 -> 23.18 tok/s`) and **2.36x faster decode / 1.55x faster prefill at 256K** on NVIDIA A10G (`18.64 -> 44.06 tok/s`, `543.05 -> 841.19 tok/s`), plus **+50% to +68% decode speedup** at 8K-64K via the bundled MTP draft head (`--spec-type draft-mtp --spec-draft-n-max 2`).- **Bonsai-2.5-distilled QSA indexers (`bonsai25-qsa-indexers.safetensors`)**: Warm-started from `higa2515` v2 and distilled directly against `Ternary-Bonsai-2.5-27B`'s own `PTQ1_0` dense attention distributions, cutting validation KL across all 16 full-attention layers by **19.3%** (`0.4102 -> 0.3309`; Layer 59 by **40.5%**, `0.8382 -> 0.4987`) and delivering the lowest long-context prose perplexity delta among tested indexers (**+1.155%** at 64K English PG-19, **+0.741%** at 32K Japanese Wikipedia, **+0.126%** at 32K Python code).- **Verified retention & capability parity**: **100%** multi-depth decoy needle recall at 64K (`8/8`), 128K (`5/5`), and 256K (`5/5`); **100%** on NoLiMa zero-lexical-overlap semantic paraphrase QA (`8/8` at 64K & 128K) and Japanese 64K 4-turn constraint/memory retention (`8/8`); **201/240 (83.75%)** on the hard 8-task `recall-grid` 128K benchmark (`Dense`: `225/240`, `higa2515-v2`: `202/240`); and **98.4%-100.0%** exact answer parity vs Dense on GSM8K-30 (`26/30`), Python coding execution (`19/20`), and OpenAI `tool_calls` (`12/12`).---## Repository Contents| File | Size | Description ||---|---:|---|| `Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf` | 6.14 GiB | Ready-to-run GGUF: 866 verbatim `PTQ1_0` + MTP tensors + 80 FP32 distilled QSA indexer tensors (`top_k=2048`, `block_size=4`). || `bonsai25-qsa-indexers.safetensors` | 200 MiB | Standalone 80 FP32 QSA indexer tensors (`52,434,944` params, un-folded zero-centered norms). || `patches/bonsai-qsa-engine.patch` | 70 KiB | Unified patch against `PrismML-Eng/llama.cpp` (`prism` branch) adding QSA graph, `qsa-attn.cu` (`F16`/`Q8_0` + Hadamard KV), and `libqsacap.so`. || `scripts/bonsai_qsa_graft.py` | 8 KiB | Zero-dependency Python script to graft FP32 QSA indexers onto `Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf` without re-quantizing base tensors. || `benchmarks/` | ~68 KiB | Complete raw benchmark summaries (`*.json`) and interactive 128K `recall-grid` heatmap report (`recall_grid_128k.html`). || `SHA256SUMS` / `release-manifest.json` | ~5 KiB | Cryptographic checksums and provenance metadata for every release file. |---## Quick Start### 1. Download and Verify```bashhf download sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF \8 unmodified lines)```### 2. Build the Patched `llama.cpp` Engine (CUDA or CPU)Requirements: CMake 3.20+, Ninja, Python 3.10+, and CUDA Toolkit 12+ (for GPU inference).```bashcd ./bonsai-2.5-qsa7 unmodified linescmake --build bonsai-qsa-engine/build-cuda --target llama-cli llama-server llama-perplexity -j "$(nproc)"```*(Optional)* To reproduce the GGUF locally from PrismML's base file and `bonsai25-qsa-indexers.safetensors`:```bashpython3 scripts/bonsai_qsa_graft.py \Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf \bonsai25-qsa-indexers.safetensors \Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf```### 3. Run Inference```bash# Single 24 GB GPU: full 256K context (262,144 tokens, ~15.85 GiB VRAM)./bonsai-qsa-engine/build-cuda/bin/llama-server \-m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \-ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 262144 -np 1 -b 512 -ub 512# Single 16 GB GPU: 64K context + built-in MTP speculative decoding (~1.5x-1.7x decode)./bonsai-qsa-engine/build-cuda/bin/llama-server \-m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \-ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 65536 -np 1 -b 512 -ub 512 \--spec-type draft-mtp --spec-draft-n-max 2# Toggle Dense full attention on the exact same GGUF for A/B quality comparison:LLAMA_QSA_DENSE=1 ./bonsai-qsa-engine/build-cuda/bin/llama-server ...```---## Comprehensive BenchmarksAll quality comparisons below evaluate the **exact same `Ternary-Bonsai-2.5-27B-PTQ1_0` backbone**, engine binary, `Q8_0` KV cache (`-fa on -ctk q8_0 -ctv q8_0`), greedy decoding (`temperature=0.0, top_k=1`), and GPU, switching only the 80 FP32 QSA indexer tensors or `LLAMA_QSA_DENSE=1`.### 1. Throughput and Peak VRAM (Single GPU, 8K to 256K)1 unmodified line|---|---|---:|---:|---:|---:|---:|| Tesla T4 (16 GB) | Dense (`F16` KV) | 8,192 | 5,834 | 310.54 | 30.05 | 6,667 || Tesla T4 (16 GB) | QSA (`F16` KV) | 8,192 | 5,834 | 298.72 | 27.49 | 6,675 || Tesla T4 (16 GB) | QSA (`F16` KV) + MTP | 8,192 | 5,834 | 287.82 | 44.31 | 7,351 || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 65,536 | 55,886 | 221.71 | 24.50 | 8,555 || Tesla T4 (16 GB) | QSA (`Q8_0` KV) + MTP | 65,536 | 55,886 | 213.26 | 36.63 | 9,457 || Tesla T4 (16 GB) | Dense (`Q8_0` KV) | 131,072 | 117,806 | 138.58 | 5.37 | 11,109 || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 131,072 | 117,806 | 214.49 | 23.18 | 11,031 || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 196,608 | 179,898 | 208.82 | 21.51 | 13,551 || NVIDIA A10G (24 GB) | Dense (`F16` KV) | 8,192 | 5,831 | 1,109.30 | 58.71 | 6,839 || NVIDIA A10G (24 GB) | QSA (`F16` KV) | 8,192 | 5,831 | 1,084.22 | 51.49 | 6,847 || NVIDIA A10G (24 GB) | QSA (`F16` KV) + MTP | 8,192 | 5,831 | 1,014.78 | 86.47 | 7,523 || NVIDIA A10G (24 GB) | Dense (`Q8_0` KV) | 131,072 | 117,803 | 752.32 | 30.08 | 11,281 || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV, blk-kernel) | 131,072 | 117,803 | 885.56 | 48.43 | 11,203 || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV) + MTP | 131,072 | 117,803 | 833.23 | 50.41 | 12,425 || NVIDIA A10G (24 GB) | Dense (`Q8_0` KV) | 262,144 | 239,923 | 543.05 | 18.64 | 16,305 || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV, blk-kernel) | 262,144 | 239,923 | **841.19** | **44.06** | **16,227** || NVIDIA L40S (48 GB) | QSA (`Q8_0` KV, blk-kernel) | 262,144 | 239,923 | 2,224.38 | 58.09 | 16,430 |*Note on 256K + MTP*: At 256K (`262,144`), the bundled `blk.64` MTP head attends densely over KV history unless bounded via `--spec-draft-window`, making plain QSA faster and lower-VRAM (`44.06 tok/s`, `16,227 MiB` vs `37.65 tok/s`, `18,089 MiB` with unbounded MTP on A10G).### 2. Hard 128K Structured Recall & Anti-Mixup (`recall-grid` 128K, 240 Questions)Evaluated with `qsa-indexer-forge/scripts/recall_grid/recall_grid.py` (`seed=20261202`, held-out `emozilla/pg19` validation 50 books, `doc_tokens=[127123, 127104]`, `grid_content_sha256=e9334402e6a6...`, 8 task types × 10 depths × 3 = **240 questions**, 15% background record clutter, 1-character look-alike hard negatives, `thinking off`, `max_tokens=1024`, NVIDIA L40S).| Arm | Total | Accuracy | `guid` | `pointer` | `ingredients` | `quantities` | `revision` | `join` | `code` | `binding` | Cut-off ||---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|1 unmodified line| `higa2515-v2` (zero-shot graft) | 202/240 | 84.17% | 26/30 | 26/30 | 27/30 | 21/30 | 23/30 | 28/30 | 26/30 | 25/30 | 11 || **`Bonsai-2.5 distilled v1` (this release)** | **201/240** | **83.75%** | 26/30 | 24/30 | 27/30 | 21/30 | 24/30 | 28/30 | 27/30 | 24/30 | 10 |- **Paired exact two-sided McNemar tests**:- `bonsai25_v1` vs `higa2515_v2`: `6` vs `7` discordant items (**`p = 1.0`**, statistically indistinguishable on 128K `recall-grid`).- `bonsai25_v1` vs `Dense`: `4` vs `28` (**`p = 1.9e-5`**).- `higa2515_v2` vs `Dense`: `7` vs `30` (**`p = 0.000191`**).- **Error taxonomy (`bonsai25_v1` vs `higa2515_v2` vs `Dense`)**:- Wrong ingredient set: `8` / `7` / `1`- Value of another record (mostly multi-hop `pointer`): `8` / `6` / `2`- Value instead of `null` (`revision` / `binding`): `7` / `7` / `6`- 1-character look-alike decoy: `5` / `6` / `1`- Cut off at `max_tokens=1024`: `10` / `11` / `3`- See `benchmarks/recall_grid_128k.html` for the complete 10-depth × 8-task interactive heatmap and failure examples.### 3. Long-Context Language Modeling Perplexity (`llama-perplexity`)Evaluated on strictly held-out corpora (`emozilla/pg19` `test` split, `wikimedia/wikipedia` `20231101.ja` skipped past row 1,200, and Python standard library source files) using `Q8_0` KV cache (`-fa on -ctk q8_0 -ctv q8_0`) on NVIDIA L40S.| Corpus & Window | Sparsity | Dense (`PPL ± SE`) | `Bonsai-2.5 v1` (`Δ%`) | `higa2515-v2` (`Δ%`) | `pentacoxian-255k` (`Δ%`) ||---|---:|---:|---:|---:|---:|3 unmodified lines| **Japanese Wikipedia (`32K`, 16K-32K tail)** | **87.5-93.8%** | `11.9643 ± 0.2621` | **`12.0530` (`+0.741%`)** | `12.0596` (`+0.797%`) | `12.0676` (`+0.863%`) || Python Stdlib Code (`32K`, 16K-32K tail) | 87.5-93.8% | `1.7518 ± 0.0213` | `1.7540` (`+0.126%`) | `1.7539` (`+0.120%`) | `1.7535` (`+0.097%`) |### 4. Forgetting, Semantic Paraphrase, Multi-Turn & 256K Needle Stress Suite| Test Suite | Context | `Dense` | `Bonsai-2.5 v1` | `higa2515-v2` | `pentacoxian-255k` ||---|---:|---:|---:|---:|---:|12 unmodified linesEvaluated at `ctx=8192` (`Q8_0` KV, `thinking off`, greedy) on NVIDIA L40S:| Configuration | GSM8K (test[:30]) | Python Coding Exec (20 unit tests) | OpenAI `tool_calls` (EN+JA, 12 tasks) | Total (62) | Exact Parity vs Dense ||---|---:|---:|---:|---:|---:|| `Dense` (`LLAMA_QSA_DENSE=1`) | 25/30 (83.3%) | 19/20 (95.0%) | 12/12 (100%) | 56/62 (90.3%) | baseline || **`Bonsai-2.5 distilled v1` (QSA)** | **26/30 (86.7%)** | **19/20 (95.0%)** | **12/12 (100%)** | **57/62 (91.9%)** | **61/62 (98.4%)** || **`Bonsai-2.5 distilled v1` (QSA + MTP)** | **25/30 (83.3%)** | **19/20 (95.0%)** | **12/12 (100%)** | **56/62 (90.3%)** | **62/62 (100.0%)** |### 6. Bonsai-2.5 Indexer Distillation Metrics (`v2` Warm-Start -> `bonsai25-v1`)50-step KL + top-128 restricted-KL + decoy-margin distillation (`seq_len=12,288`, `lr=5e-5 -> 5e-6`, `AdamW`, captured directly from `Ternary-Bonsai-2.5-27B-PTQ1_0` via `libqsacap.so` on 1x NVIDIA L40S):| Metric (Held-Out 8-Seq Validation, `seq_len=12,288`) | `higa2515-v2` Zero-Shot | `Bonsai-2.5 distilled v1` | Change ||---|---:|---:|---:|3 unmodified lines| Single-Layer Answer > Decoy Score Win Rate | `43.43%` | **`49.06%`** | **+5.62 pp** || Tight Top-64 / Top-512 Answer Block Recall | `93.05%` / `99.93%` | **`93.40%` / `99.96%`** | **+0.35 pp / +0.02 pp** |---## Architecture & Hadamard Compatibility`Ternary-Bonsai-2.5-27B` applies normalized Sylvester Walsh-Hadamard rotation (`prism.hadamard.axis = input-last-dimension`) strictly to the 401 ternary linear weights listed in `prism.hadamard.weight_names`, while `token_embd.weight` stores the inverse transform. Consequently, the residual stream and `attn_norm` outputs remain in `Qwen3.8-27B`'s unrotated primal basis:1. The 16 QSA indexers (full-attention layers `3, 7, ..., 63`, 4-token pooled blocks, `top_k=2048` = 512 blocks + causal own block) read `attn_norm` directly with no extra Hadamard transform.2. When `-ctk q8_0 -ctv q8_0` activates Hadamard KV cache rotation (`self_k_rot`, `self_v_rot`), `qsa-attn.cu` computes exact inner products on the rotated Q/K blocks selected by the indexer and un-rotates the attention output via `llama_mul_mat_hadamard(ctx0, cur, inp->self_v_rot)`.3. No `[n_kv, n_tokens]` dense mask buffer is allocated during sparse attention, keeping peak VRAM at `16,227 MiB` for `262,144` context.---## Known Limitations & Scope- **Stage 1 indexer distillation only**: The 1.75 bpw ternary backbone and `blk.64` MTP head are frozen verbatim; Stage 2 sparse-attention backbone adaptation has not been performed.- **128K `recall-grid` gap vs Dense**: Under `thinking off`, a statistically significant gap remains (`201/240` vs `225/240`, `p = 1.9e-5`), driven primarily by multi-record aggregation (`quantities`/`ingredients`), multi-hop `pointer` chains, and `null` traps when `K=2,048` covers only `1.6%` of 128K context. Because `v1` distilled for 50 steps at `12K`, its 128K `recall-grid` accuracy matches its `higa2515-v2` parent (`201` vs `202`, `p=1.0`) while improving long-context PPL (`+1.155%` vs `+1.273%` at 64K EN; `+0.741%` vs `+0.797%` at 32K JA) and late-layer KL (`-40.5%` at Layer 59). A future `v2` trained at 64K on multi-hop mixup tasks could narrow this gap further.- **MTP at 256K**: Use plain QSA without MTP (or bound draft attention with `--spec-draft-window`) at 256K; reserve unbounded MTP for 8K-128K.- **Text-only & single-GPU validated**: Verified on Linux x86_64 CPU and single NVIDIA GPUs (`sm_75`, `sm_86`, `sm_89`). Vision `mmproj` and multi-GPU tensor-parallel splits are not validated in this release.---## License & Attribution- Model weights, distilled QSA indexers, grafting script, and documentation: **Apache-2.0** (`LICENSE`).- `patches/bonsai-qsa-engine.patch`: **MIT** (derived from `PrismML-Eng/llama.cpp`).- Full upstream notices and provenance: see [`NOTICE.md`](NOTICE.md) and [`release-manifest.json`](release-manifest.json).---## 日本語概要 (Japanese Summary)`Ternary-Bonsai-2.5-27B-QSA` は、PrismML 製の三値量子化モデル [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF)(1.75 bpw `PTQ1_0` + MTP 内蔵、866 テンソルを無変換コピー)に、Bonsai-2.5 自身の密アテンション分布で蒸留した FP32 QSA インデクサー 80 テンソルを統合した **6.14 GiB** の GGUF モデルです。- **速度と VRAM**: `Q8_0` KV キャッシュ向けの専用ブロック疎 CUDA カーネルにより、単一 24 GB GPU(A10G)で **256K 文脈(262,144 トークン)を 15.85 GiB VRAM** で実行でき、Dense 比で **2.36 倍**のデコード速度(`18.64 → 44.06 tok/s`)を出します。16 GB GPU(Tesla T4)でも 128K で **4.32 倍**(`5.37 → 23.18 tok/s`)、192K を `13.23 GiB` VRAM で動作します。- **品質と制限**: 8K の一般 62 問(GSM8K / Python 実行 / tool_calls)は Dense と **98.4%〜100%** 一致し、32K 日本語 Wiki PPL の変化は **+0.74%**、64K 英語 PG-19 PPL の変化は **+1.16%** に収まります。一方、128K `recall-grid`(240 問・thinking off)では Dense `225/240`(93.75%)に対し QSA `201/240`(83.75%)と `-10.0 pt` の差が残るため、精度と速度のトレードオフを踏まえて使い分けてください。- **実行要件**: 素の `llama.cpp` では動作しません。`PrismML-Eng/llama.cpp`(`prism` ブランチ)に同梱の `patches/bonsai-qsa-engine.patch` を適用してビルドしてください。環境変数 `LLAMA_QSA_DENSE=1` で同一 GGUF のまま Dense 推論へ切り替えられます。29 unmodified lines303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889908 unmodified lines991001011021031041051061077 unmodified lines1151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931 unmodified line1951961971981992002012022032042052062072082092102112122132142152162172182192202211 unmodified line2232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662673 unmodified lines27127227327427527627712 unmodified lines2902912922932942952962972982993003013023033043 unmodified lines30830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940029 unmodified lines# Ternary-Bonsai-2.5-27B-QSA (GGUF)**English** | [日本語](README.ja.md)[](https://arxiv.org/abs/2608.30320)[](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF)[](#model-specifications)[](#hardware-and-vram-guide)[](LICENSE)`Ternary-Bonsai-2.5-27B-QSA` combines PrismML's 1.75 bpw ternary model [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF) (all 866 tensors copied verbatim, including its bundled `blk.64` Multi-Token Prediction draft head) with 80 FP32 **Qwen Sparse Attention (QSA)** indexer tensors distilled directly against `Ternary-Bonsai-2.5-27B`'s own `PTQ1_0` dense attention distributions, packaged as a single **6.14 GiB GGUF** with a matching `llama.cpp` CUDA/CPU patch.> [!IMPORTANT]> **Engine requirement**: Stock `llama.cpp` cannot run QSA GGUFs. Apply [`patches/bonsai-qsa-engine.patch`](patches/bonsai-qsa-engine.patch) to `PrismML-Eng/llama.cpp` (`prism` branch) to enable the `qsa-attn.cu` zero-mask block-sparse CUDA kernel (`F16` and `Q8_0` KV cache with Hadamard rotation) and the `LLAMA_QSA_DENSE=1` toggle for exact dense A/B comparison on the same file.## Highlights- **256K context (`262,144` tokens) in 15.85 GiB VRAM (`16,227 MiB`)** on a single 24 GB GPU, and **192K context (`196,608` tokens) in 13.23 GiB VRAM (`13,551 MiB`)** on a single 16 GB Tesla T4 (`-ctk q8_0 -ctv q8_0 -fa on -np 1`).- **Up to 4.32x decode speedup at 128K** on Tesla T4 (`5.37 -> 23.18 tok/s`, prefill `1.55x`) and **2.36x decode / 1.55x prefill speedup at 256K** on NVIDIA A10G (`18.64 -> 44.06 tok/s`, `543.05 -> 841.19 tok/s`). At 8K to 64K, the bundled `blk.64` MTP head adds **+50% to +68%** decode throughput (`--spec-type draft-mtp --spec-draft-n-max 2`).- **Bonsai-2.5-distilled QSA indexers (`bonsai25-qsa-indexers.safetensors`)**: Warm-started from `higa2515` v2 and distilled on `Ternary-Bonsai-2.5-27B-PTQ1_0` dense attention, reducing held-out validation KL across all 16 attention layers by **19.3%** (`0.4102 -> 0.3309`; Layer 59 by **40.5%**, `0.8382 -> 0.4987`) and achieving the lowest long-context prose perplexity delta among tested indexers (**+1.155%** at 64K English PG-19, **+0.741%** at 32K Japanese Wikipedia, **+0.126%** at 32K Python code).- **Verified retention and short-context parity**: **100%** multi-depth decoy needle recall at 64K (`8/8`), 128K (`5/5`), and 256K (`5/5`); **100%** on NoLiMa zero-lexical-overlap semantic paraphrase QA (`8/8` at 64K and 128K) and Japanese 64K 4-turn constraint memory (`8/8`); **201/240 (83.75%)** on hard 128K `recall-grid` (`Dense`: `225/240`, `higa2515-v2`: `202/240`); and **98.4% to 100.0%** exact answer parity vs Dense on 62 general tasks (GSM8K-30, Python coding execution, OpenAI `tool_calls`).---## Model Specifications| Property | Value ||---|---|| Base model | [`prism-ml/Ternary-Bonsai-2.5-27B-GGUF`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF) (`Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf`, derived from `Qwen/Qwen3.8-27B`) || Architecture | 64-layer hybrid (48 Gated DeltaNet + 16 QSA full-attention layers at `3, 7, ..., 63`) + `blk.64` MTP draft head || Weight format | 1.75 bpw ternary `PTQ1_0` (866 base tensors verbatim, no re-quantization) + 80 FP32 QSA indexer tensors (`52,434,944` params, 200 MiB) || GGUF file size | **6.14 GiB** (`6,442,564,320` bytes, 946 tensors total) || QSA sparse configuration | `block_size = 4`, `top_k = 2048` (512 blocks + causal own block = max 2,052 KV tokens attended), 4 Q-heads / 1 K-head, `head_dim = 128`, `rope_dim = 64` || Native / tested context | Up to **262,144 tokens (256K)** verified on a single 24 GB GPU || Engine patch | `patches/bonsai-qsa-engine.patch` against `PrismML-Eng/llama.cpp` (`prism` branch) || Licenses | Apache-2.0 (weights, indexers, scripts, docs); MIT (`patches/bonsai-qsa-engine.patch`) |---## Hardware and VRAM GuideMeasured single-GPU configurations (`-ngl 999 -fa on -np 1 -b 512 -ub 512`). All 48 Gated DeltaNet layers use `O(1)` recurrent state; KV cache grows only on the 16 full-attention layers, and `qsa-attn.cu` allocates no `[n_kv, n_tokens]` dense attention mask buffer.| GPU Class | Practical Context | KV Cache | Measured Peak VRAM | Recommended MTP | Measured Decode (`tok/s`) ||---|---:|---|---:|---|---:|| 12 GB GPU (e.g. RTX 3060 / 4070) | 64K to 96K | `q8_0` | ~8.6 to 9.9 GiB | `--spec-type draft-mtp --spec-draft-n-max 2` (up to 64K) | Scales with memory BW || 16 GB GPU (Tesla T4, `sm_75`) | **128K to 192K** | `q8_0` | **10.77 GiB** (128K) / **13.23 GiB** (192K) | Enable for 8K to 64K (`36.6` to `44.3 tok/s`) | **23.18** (128K) / **21.51** (192K) || 24 GB GPU (A10G / RTX 3090 / 4090) | **256K** | `q8_0` | **15.85 GiB** (256K) | Enable for 8K to 128K (`50.4` to `86.5 tok/s`); omit at 256K | **44.06** (256K on A10G) || 48 GB GPU (L40S / A6000) | **256K** | `q8_0` or `f16` | **16.04 GiB** (`q8_0` at 256K) | Optional (`--spec-draft-window` at 256K) | **58.09** (256K, `2,224` PP) |---## Quick Start### 1. Download and Verify Checksums```bashhf download sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF \8 unmodified lines)```### 2. Build the Patched Engine (CUDA or CPU)Requirements: CMake 3.20+, Ninja, Python 3.10+, and CUDA Toolkit 12+ for GPU builds (drop `-DGGML_CUDA=ON` for CPU-only builds).```bashcd ./bonsai-2.5-qsa7 unmodified linescmake --build bonsai-qsa-engine/build-cuda --target llama-cli llama-server llama-perplexity -j "$(nproc)"```### 3. Serve and Test```bash# Single 24 GB GPU: full 256K context (~15.85 GiB VRAM)./bonsai-qsa-engine/build-cuda/bin/llama-server \-m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \-ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 262144 -np 1 -b 512 -ub 512 \--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --presence-penalty 0.0 --repeat-penalty 1.0# Single 16 GB GPU: 64K context + built-in MTP speculative decoding (+50% to +68% decode)./bonsai-qsa-engine/build-cuda/bin/llama-server \-m ./Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf \-ngl 999 -fa on -ctk q8_0 -ctv q8_0 -c 65536 -np 1 -b 512 -ub 512 \--spec-type draft-mtp --spec-draft-n-max 2 \--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --presence-penalty 0.0 --repeat-penalty 1.0# Exact Dense full-attention A/B check on the same GGUF:LLAMA_QSA_DENSE=1 ./bonsai-qsa-engine/build-cuda/bin/llama-server ...```Quick OpenAI-compatible API test:```bashcurl -s http://127.0.0.1:8080/v1/chat/completions \-H "Content-Type: application/json" \-d '{"model": "Ternary-Bonsai-2.5-27B-QSA","messages": [{"role": "user", "content": "Explain why block-sparse attention speeds up long-context decoding in two sentences."}],"temperature": 0.7,"top_p": 0.8,"top_k": 20,"min_p": 0.0,"presence_penalty": 1.5,"max_tokens": 256}'```<details><summary>Optional: Rebuild the GGUF locally from PrismML's base file and standalone indexers</summary>```bashpython3 scripts/bonsai_qsa_graft.py \Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf \bonsai25-qsa-indexers.safetensors \Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf````scripts/bonsai_qsa_graft.py` uses Python's standard library only and copies all 866 `PTQ1_0` and MTP tensors verbatim without re-quantizing.</details>---## Recommended Sampling ParametersFollowing upstream `prism-ml/Ternary-Bonsai-2.5-27B-GGUF` and `Qwen/Qwen3.8-27B` guidance:| Mode | `temperature` | `top_p` | `top_k` | `min_p` | `presence_penalty` | `repetition_penalty` ||---|---:|---:|---:|---:|---:|---:|| **Thinking mode** (default reasoning) | `1.0` | `0.95` | `20` | **`0.0`** | `0.0` | `1.0` || **Non-thinking / Instruct mode** | `0.7` | `0.80` | `20` | **`0.0`** | `1.5` | `1.0` || **Deterministic evaluation** | `0.0` | `1.0` | `1` | `0.0` | `0.0` | `1.0` |> [!TIP]> Always pass `--min-p 0` explicitly in `llama.cpp`. Its default is `--min-p 0.05`, which diverges from the recommended `min_p=0.0` setting and can cause premature truncation in long reasoning traces.---## BenchmarksAll quality comparisons below evaluate the **exact same `Ternary-Bonsai-2.5-27B-PTQ1_0` backbone**, engine binary, `Q8_0` KV cache (`-fa on -ctk q8_0 -ctv q8_0`), greedy decoding (`temperature=0.0, top_k=1`), and GPU, changing only the 80 FP32 QSA indexer tensors or `LLAMA_QSA_DENSE=1`.### 1. Throughput and Peak VRAM (Single GPU, 8K to 256K)1 unmodified line|---|---|---:|---:|---:|---:|---:|| Tesla T4 (16 GB) | Dense (`F16` KV) | 8,192 | 5,834 | 310.54 | 30.05 | 6,667 || Tesla T4 (16 GB) | QSA (`F16` KV) | 8,192 | 5,834 | 298.72 | 27.49 | 6,675 || Tesla T4 (16 GB) | QSA (`F16` KV) + MTP | 8,192 | 5,834 | 287.82 | **44.31** | 7,351 || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 65,536 | 55,886 | 221.71 | 24.50 | 8,555 || Tesla T4 (16 GB) | QSA (`Q8_0` KV) + MTP | 65,536 | 55,886 | 213.26 | **36.63** | 9,457 || Tesla T4 (16 GB) | Dense (`Q8_0` KV) | 131,072 | 117,806 | 138.58 | 5.37 | 11,109 || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 131,072 | 117,806 | **214.49** | **23.18** | **11,031** || Tesla T4 (16 GB) | QSA (`Q8_0` KV, blk-kernel) | 196,608 | 179,898 | 208.82 | 21.51 | 13,551 || NVIDIA A10G (24 GB) | Dense (`F16` KV) | 8,192 | 5,831 | 1,109.30 | 58.71 | 6,839 || NVIDIA A10G (24 GB) | QSA (`F16` KV) | 8,192 | 5,831 | 1,084.22 | 51.49 | 6,847 || NVIDIA A10G (24 GB) | QSA (`F16` KV) + MTP | 8,192 | 5,831 | 1,014.78 | **86.47** | 7,523 || NVIDIA A10G (24 GB) | Dense (`Q8_0` KV) | 131,072 | 117,803 | 752.32 | 30.08 | 11,281 || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV, blk-kernel) | 131,072 | 117,803 | **885.56** | **48.43** | **11,203** || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV) + MTP | 131,072 | 117,803 | 833.23 | 50.41 | 12,425 || NVIDIA A10G (24 GB) | Dense (`Q8_0` KV) | 262,144 | 239,923 | 543.05 | 18.64 | 16,305 || NVIDIA A10G (24 GB) | QSA (`Q8_0` KV, blk-kernel) | 262,144 | 239,923 | **841.19** | **44.06** | **16,227** || NVIDIA L40S (48 GB) | QSA (`Q8_0` KV, blk-kernel) | 262,144 | 239,923 | **2,224.38** | **58.09** | 16,430 |*Note on 256K + MTP*: At 256K (`262,144`), the bundled `blk.64` MTP head attends densely over KV history unless bounded with `--spec-draft-window`, so plain QSA is faster and uses less VRAM (`44.06 tok/s`, `16,227 MiB` vs `37.65 tok/s`, `18,089 MiB` with unbounded MTP on A10G).### 2. Hard 128K Structured Recall (`recall-grid` 128K, 240 Questions)Evaluated with `recall_grid.py` (`seed=20261202`, held-out `emozilla/pg19` validation 50 books, `doc_tokens=[127123, 127104]`, `grid_content_sha256=e9334402e6a6...`, 8 task types x 10 depths x 3 = **240 questions**, 15% background record clutter, 1-character look-alike hard negatives, `thinking off`, `max_tokens=1024`, NVIDIA L40S).| Arm | Total | Accuracy | `guid` | `pointer` | `ingredients` | `quantities` | `revision` | `join` | `code` | `binding` | Cut-off ||---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|1 unmodified line| `higa2515-v2` (zero-shot graft) | 202/240 | 84.17% | 26/30 | 26/30 | 27/30 | 21/30 | 23/30 | 28/30 | 26/30 | 25/30 | 11 || **`Bonsai-2.5 distilled v1` (this release)** | **201/240** | **83.75%** | 26/30 | 24/30 | 27/30 | 21/30 | 24/30 | 28/30 | 27/30 | 24/30 | 10 |- **Paired exact two-sided McNemar tests**: `bonsai25_v1` vs `higa2515_v2` is `6` vs `7` discordant items (**`p = 1.0`**, statistically indistinguishable); `bonsai25_v1` vs `Dense` is `4` vs `28` (**`p = 1.9e-5`**); `higa2515_v2` vs `Dense` is `7` vs `30` (**`p = 0.000191`**).- Interactive 10-depth x 8-task heatmap and failure examples: [`benchmarks/recall_grid_128k.html`](benchmarks/recall_grid_128k.html).<details><summary>Detailed 128K recall-grid error taxonomy and depth-bin breakdown</summary>#### Error Taxonomy (`bonsai25_v1` / `higa2515_v2` / `Dense`)| Error Class | `Bonsai-2.5 v1` | `higa2515-v2` | `Dense` ||---|---:|---:|---:|| Wrong ingredient set (`quantities` / `ingredients`) | 8 | 7 | 1 || Value of another record (mostly multi-hop `pointer`) | 8 | 6 | 2 || Value instead of `null` (`revision` / `binding`) | 7 | 7 | 6 || 1-character look-alike decoy (`guid` / `code`) | 5 | 6 | 1 || Cut off: long working (`max_tokens=1024`) | 6 | 8 | 3 || Cut off: listing records (`max_tokens=1024`) | 4 | 3 | 0 || `null` instead of value (`revision`) | 1 | 1 | 0 || Right set, wrong amounts (`quantities`) | 0 | 0 | 2 |#### Accuracy by Document Depth Bin (24 questions per bin)| Depth Bin | `Dense` | `Bonsai-2.5 v1` | `higa2515-v2` ||---|---:|---:|---:|| 0-10% | 24/24 (100%) | 23/24 (96%) | 23/24 (96%) || 10-20% | 23/24 (96%) | 21/24 (88%) | 21/24 (88%) || 20-30% | 22/24 (92%) | 20/24 (83%) | 20/24 (83%) || 30-40% | 22/24 (92%) | 18/24 (75%) | 19/24 (79%) || 40-50% | 23/24 (96%) | 20/24 (83%) | 21/24 (88%) || 50-60% | 22/24 (92%) | 17/24 (71%) | 16/24 (67%) || 60-70% | 23/24 (96%) | 21/24 (88%) | 23/24 (96%) || 70-80% | 20/24 (83%) | 19/24 (79%) | 19/24 (79%) || 80-90% | 22/24 (92%) | 21/24 (88%) | 20/24 (83%) || 90-100% | 24/24 (100%) | 21/24 (88%) | 20/24 (83%) |</details>### 3. Long-Context Language Modeling Perplexity (`llama-perplexity`)Evaluated on strictly held-out corpora (`emozilla/pg19` `test`, `wikimedia/wikipedia` `20231101.ja` past row 1,200, and Python standard library source files) using `Q8_0` KV cache (`-fa on -ctk q8_0 -ctv q8_0`) on NVIDIA L40S.| Corpus & Window | Sparsity | Dense (`PPL ± SE`) | `Bonsai-2.5 v1` (`Δ%`) | `higa2515-v2` (`Δ%`) | `pentacoxian-255k` (`Δ%`) ||---|---:|---:|---:|---:|---:|3 unmodified lines| **Japanese Wikipedia (`32K`, 16K-32K tail)** | **87.5-93.8%** | `11.9643 ± 0.2621` | **`12.0530` (`+0.741%`)** | `12.0596` (`+0.797%`) | `12.0676` (`+0.863%`) || Python Stdlib Code (`32K`, 16K-32K tail) | 87.5-93.8% | `1.7518 ± 0.0213` | `1.7540` (`+0.126%`) | `1.7539` (`+0.120%`) | `1.7535` (`+0.097%`) |### 4. Forgetting, Semantic Paraphrase, Multi-Turn & 256K Needle Suite| Test Suite | Context | `Dense` | `Bonsai-2.5 v1` | `higa2515-v2` | `pentacoxian-255k` ||---|---:|---:|---:|---:|---:|12 unmodified linesEvaluated at `ctx=8192` (`Q8_0` KV, `thinking off`, greedy) on NVIDIA L40S:| Configuration | GSM8K (`test[:30]`) | Python Coding Exec (20 unit tests) | OpenAI `tool_calls` (EN+JA, 12 tasks) | Total (62) | Exact Parity vs Dense ||---|---:|---:|---:|---:|---:|| `Dense` (`LLAMA_QSA_DENSE=1`) | 25/30 (83.3%) | 19/20 (95.0%) | 12/12 (100%) | 56/62 (90.3%) | baseline || **`Bonsai-2.5 distilled v1` (QSA)** | **26/30 (86.7%)** | **19/20 (95.0%)** | **12/12 (100%)** | **57/62 (91.9%)** | **61/62 (98.4%)** || **`Bonsai-2.5 distilled v1` (QSA + MTP)** | **25/30 (83.3%)** | **19/20 (95.0%)** | **12/12 (100%)** | **56/62 (90.3%)** | **62/62 (100.0%)** |### 6. Bonsai-2.5 Indexer Distillation (`v2` Warm-Start -> `bonsai25-v1`)50-step KL + top-128 restricted-KL + decoy-margin distillation (`seq_len=12,288`, `lr=5e-5 -> 5e-6`, `AdamW`, captured directly from `Ternary-Bonsai-2.5-27B-PTQ1_0` via `libqsacap.so` on 1x NVIDIA L40S, peak training VRAM `2.60 GiB`, total wall time `33.9 min`):| Metric (Held-Out 8-Seq Validation, `seq_len=12,288`) | `higa2515-v2` Zero-Shot | `Bonsai-2.5 distilled v1` | Change ||---|---:|---:|---:|3 unmodified lines| Single-Layer Answer > Decoy Score Win Rate | `43.43%` | **`49.06%`** | **+5.62 pp** || Tight Top-64 / Top-512 Answer Block Recall | `93.05%` / `99.93%` | **`93.40%` / `99.96%`** | **+0.35 pp / +0.02 pp** |<details><summary>Full per-layer validation KL divergence across all 16 QSA attention layers</summary>| Layer | `higa2515-v2` Zero-Shot KL | `Bonsai-2.5 distilled v1` KL | Relative Reduction ||---:|---:|---:|---:|| 3 | 0.25779 | 0.22018 | -14.6% || 7 | 0.29763 | 0.27563 | -7.4% || 11 | 0.32785 | 0.29977 | -8.6% || 15 | 0.34878 | 0.31775 | -8.9% || 19 | 0.31742 | 0.29727 | -6.3% || 23 | 0.31485 | 0.29990 | -4.7% || 27 | 0.32383 | 0.29966 | -7.5% || 31 | 0.30497 | 0.27806 | -8.8% || 35 | 0.49230 | 0.37172 | -24.5% || 39 | 0.34296 | 0.30800 | -10.2% || 43 | 0.41586 | 0.35054 | -15.7% || 47 | 0.33185 | 0.29662 | -10.6% || 51 | 0.50544 | 0.37346 | -26.1% || 55 | 0.63538 | 0.40404 | -36.4% || 59 | 0.83821 | 0.49865 | -40.5% || 63 | 0.50756 | 0.40388 | -20.4% |</details>---## Architecture and Hadamard Compatibility`Ternary-Bonsai-2.5-27B` applies normalized Sylvester Walsh-Hadamard rotation (`prism.hadamard.axis = input-last-dimension`) strictly to the 401 ternary linear weights listed in `prism.hadamard.weight_names`, while `token_embd.weight` stores the inverse transform. As a result, the residual stream and `attn_norm` outputs remain in `Qwen3.8-27B`'s unrotated primal basis:1. All 16 QSA indexers (full-attention layers `3, 7, ..., 63`, 4-token pooled blocks, `top_k=2048` = 512 blocks + causal own block) consume `attn_norm` directly with no extra Hadamard transform.2. When `-ctk q8_0 -ctv q8_0` activates Hadamard KV cache rotation (`self_k_rot`, `self_v_rot`), `qsa-attn.cu` computes exact inner products on the rotated Q/K blocks chosen by the indexer and un-rotates the attention output via `llama_mul_mat_hadamard(ctx0, cur, inp->self_v_rot)`.3. No `[n_kv, n_tokens]` dense mask buffer is allocated during sparse attention, keeping peak VRAM at `16,227 MiB` for `262,144` context.---## Repository Contents| File | Size | Description ||---|---:|---|| [`Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf`](Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf) | 6.14 GiB | Ready-to-run GGUF: 866 verbatim `PTQ1_0` + MTP tensors + 80 FP32 distilled QSA indexer tensors (`top_k=2048`, `block_size=4`). || [`bonsai25-qsa-indexers.safetensors`](bonsai25-qsa-indexers.safetensors) | 200 MiB | Standalone 80 FP32 QSA indexer tensors (`52,434,944` params, un-folded zero-centered norms). || [`patches/bonsai-qsa-engine.patch`](patches/bonsai-qsa-engine.patch) | 70 KiB | Unified patch against `PrismML-Eng/llama.cpp` (`prism` branch) adding QSA graph, `qsa-attn.cu` (`F16`/`Q8_0` + Hadamard KV), and `libqsacap.so`. || [`scripts/bonsai_qsa_graft.py`](scripts/bonsai_qsa_graft.py) | 8 KiB | Zero-dependency Python script to graft FP32 QSA indexers onto `Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf` without re-quantizing base tensors. || [`benchmarks/`](benchmarks/) | ~72 KiB | Raw JSON benchmark logs (`*.json`) and interactive 128K `recall-grid` heatmap report (`recall_grid_128k.html`). || [`assets/`](assets/) | ~700 KiB | Publication figures embedded in the model cards (`throughput-vram.png`, `quality-benchmarks.png`, `architecture.png`). || [`README.ja.md`](README.ja.md) | ~16 KiB | Full Japanese companion model card. || [`SHA256SUMS`](SHA256SUMS) / [`release-manifest.json`](release-manifest.json) | ~6 KiB | Cryptographic checksums and provenance metadata for every release file. |---## Known Limitations and Scope- **Stage 1 indexer distillation only**: The 1.75 bpw ternary backbone and `blk.64` MTP head are frozen verbatim; Stage 2 sparse-attention backbone adaptation has not been performed.- **128K `recall-grid` gap vs Dense**: Under `thinking off`, a statistically significant gap remains (`201/240` vs `225/240`, `p = 1.9e-5`), driven primarily by multi-record aggregation (`quantities`/`ingredients`), multi-hop `pointer` chains, and `null` traps when `K=2,048` covers only `1.6%` of 128K context. Because `v1` distilled for 50 steps at `12K`, its 128K `recall-grid` accuracy matches its `higa2515-v2` parent (`201` vs `202`, `p=1.0`) while improving long-context PPL (`+1.155%` vs `+1.273%` at 64K EN; `+0.741%` vs `+0.797%` at 32K JA) and late-layer KL (`-40.5%` at Layer 59).- **MTP at 256K**: Use plain QSA without MTP (or bound draft attention with `--spec-draft-window`) at 256K; reserve unbounded MTP for 8K to 128K.- **Text-only and single-GPU validated**: Verified on Linux x86_64 CPU and single NVIDIA GPUs (`sm_75`, `sm_86`, `sm_89`). Vision `mmproj` and multi-GPU tensor-parallel splits are not validated in this release.---## License, Attribution, and Citation- Model weights, distilled QSA indexers, grafting script, and documentation: **Apache-2.0** ([`LICENSE`](LICENSE)).- `patches/bonsai-qsa-engine.patch`: **MIT** (derived from `PrismML-Eng/llama.cpp`).- Complete upstream notices and SHA-256 provenance: [`NOTICE.md`](NOTICE.md) and [`release-manifest.json`](release-manifest.json).```bibtex@article{qwen2026qsa,title = {On the Design of Qwen3.8-Next Architecture: Evaluation, Efficiency, and Training Stability},author = {Qwen Team},journal = {arXiv preprint arXiv:2608.30320},year = {2026}}@misc{prismml2026bonsai25,title = {Ternary-Bonsai-2.5-27B-GGUF},author = {PrismML},year = {2026},url = {https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF}}@misc{sahenjp2026bonsai25qsa,title = {Ternary-Bonsai-2.5-27B-QSA-GGUF},author = {sahenjp},year = {2026},url = {https://huggingface.co/sahenjp/Ternary-Bonsai-2.5-27B-QSA-GGUF}}```
12345674 unmodified lines1213141516cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE5aacbb5b8c7d2d51e15ed1340b5147e45983bba895108ae2a108bffd967118ee NOTICE.md31f4fd2eb056575a1de2ca17f8146c6215baa6683b2432f0f151f58f51476854 README.mdc800d52b78c1eeda904ca8a7b25e2f31c4f51733b60dd306db672773f12b7b68 Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf76be39fcd0bd353676e9e3065810f95d2707c350383a49eb0d77fcc6501bbddf benchmarks/bench_phase1_resume.jsonf48f9224280c62b2739a3eedc3a73ab72fd5b6c737f12ee80e550e8499607ac7 benchmarks/bench_phase1_speed_part1.jsone60ea08413024c00db38ff9e13978c20358df1167fb4d11d8e33c16578bee11c benchmarks/forgetting_ppl_cap_bench.json4 unmodified linesdca1dc651456526299ff6c562ef8371dc5ef606cd76193a215a34cf5755620a7 benchmarks/recall_grid_128k_summary.jsone39af5f21e86aa980000f22011681fed472a7afd50bec34ef1485f3aa2a0d0aa bonsai25-qsa-indexers.safetensors1a564f2030848f806f65f81fe57432b878241a20342c8dd46eb2b14abf8b4917 patches/bonsai-qsa-engine.patch5d0310799b9b3856bdd6eea38b5d04a680554f36f1df0d32ce4fdf691ad3e0c6 release-manifest.jsonaddb0a92d0ff3368abea35a08f948c968fe08b06e8ecb38d8baa88bbd7bad4fa scripts/bonsai_qsa_graft.py12345678910114 unmodified lines1617181920cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE5aacbb5b8c7d2d51e15ed1340b5147e45983bba895108ae2a108bffd967118ee NOTICE.md691387e4c61385391a616a18a5549aa085ae3c9bb4c904528aea7f0d5bfee606 README.ja.md15a5d7b19575fe10e88ba0d39246aa96e9e5b00225e00c38142b602f12abec82 README.mdc800d52b78c1eeda904ca8a7b25e2f31c4f51733b60dd306db672773f12b7b68 Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf9209cf56dfecfe1e84893397c9a2b5570d1d18c2464dfc3efceed9e89e096aa0 assets/architecture.png4530e7b7397bc4d2238126a3396370d274fba36b05e8f8fc74d07262ae665961 assets/quality-benchmarks.png66869d5187f66593dfb05ee3f9b8eaaf1851c73b44581f15aa63056fe7597e03 assets/throughput-vram.png76be39fcd0bd353676e9e3065810f95d2707c350383a49eb0d77fcc6501bbddf benchmarks/bench_phase1_resume.jsonf48f9224280c62b2739a3eedc3a73ab72fd5b6c737f12ee80e550e8499607ac7 benchmarks/bench_phase1_speed_part1.jsone60ea08413024c00db38ff9e13978c20358df1167fb4d11d8e33c16578bee11c benchmarks/forgetting_ppl_cap_bench.json4 unmodified linesdca1dc651456526299ff6c562ef8371dc5ef606cd76193a215a34cf5755620a7 benchmarks/recall_grid_128k_summary.jsone39af5f21e86aa980000f22011681fed472a7afd50bec34ef1485f3aa2a0d0aa bonsai25-qsa-indexers.safetensors1a564f2030848f806f65f81fe57432b878241a20342c8dd46eb2b14abf8b4917 patches/bonsai-qsa-engine.patcha0d0779505f2999764c936d8cdffd0e5d97ff0ec85379c3ad720f07b61c0e0eb release-manifest.jsonaddb0a92d0ff3368abea35a08f948c968fe08b06e8ecb38d8baa88bbd7bad4fa scripts/bonsai_qsa_graft.py
49 unmodified lines5051525354555657585960616263646549 unmodified lines"bytes": 1771,"sha256": "5aacbb5b8c7d2d51e15ed1340b5147e45983bba895108ae2a108bffd967118ee"},{"path": "README.md","bytes": 19043,"sha256": "31f4fd2eb056575a1de2ca17f8146c6215baa6683b2432f0f151f58f51476854"},{"path": "Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf","bytes": 6442564320,"sha256": "c800d52b78c1eeda904ca8a7b25e2f31c4f51733b60dd306db672773f12b7b68"},{"path": "benchmarks/bench_phase1_resume.json","bytes": 7273,49 unmodified lines50515253545556575859606162636465666768697071727374757677787980818283848549 unmodified lines"bytes": 1771,"sha256": "5aacbb5b8c7d2d51e15ed1340b5147e45983bba895108ae2a108bffd967118ee"},{"path": "README.ja.md","bytes": 23160,"sha256": "691387e4c61385391a616a18a5549aa085ae3c9bb4c904528aea7f0d5bfee606"},{"path": "README.md","bytes": 24821,"sha256": "15a5d7b19575fe10e88ba0d39246aa96e9e5b00225e00c38142b602f12abec82"},{"path": "Ternary-Bonsai-2.5-27B-PTQ1_0-QSA-bonsai-v1-mtp.gguf","bytes": 6442564320,"sha256": "c800d52b78c1eeda904ca8a7b25e2f31c4f51733b60dd306db672773f12b7b68"},{"path": "assets/architecture.png","bytes": 148197,"sha256": "9209cf56dfecfe1e84893397c9a2b5570d1d18c2464dfc3efceed9e89e096aa0"},{"path": "assets/quality-benchmarks.png","bytes": 318800,"sha256": "4530e7b7397bc4d2238126a3396370d274fba36b05e8f8fc74d07262ae665961"},{"path": "assets/throughput-vram.png","bytes": 251066,"sha256": "66869d5187f66593dfb05ee3f9b8eaaf1851c73b44581f15aa63056fe7597e03"},{"path": "benchmarks/bench_phase1_resume.json","bytes": 7273,
.gitattributes+3
README.ja.mdAdded+275
README.md+222-80
SHA256SUMS+6-2
assets/architecture.pngAdded

Large File Pointer Details
- SHA256: 9209cf56dfecfe1e84893397c9a2b5570d1d18c2464dfc3efceed9e89e096aa0
- Pointer size: 131 Bytes
- Size of remote file: 148 kB
assets/quality-benchmarks.pngAdded

Large File Pointer Details
- SHA256: 4530e7b7397bc4d2238126a3396370d274fba36b05e8f8fc74d07262ae665961
- Pointer size: 131 Bytes
- Size of remote file: 319 kB
assets/throughput-vram.pngAdded

Large File Pointer Details
- SHA256: 66869d5187f66593dfb05ee3f9b8eaaf1851c73b44581f15aa63056fe7597e03
- Pointer size: 131 Bytes
- Size of remote file: 251 kB
release-manifest.json+22-2