Instructions to use PixelML/Bonsai-2-27B-W4A16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PixelML/Bonsai-2-27B-W4A16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PixelML/Bonsai-2-27B-W4A16") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("PixelML/Bonsai-2-27B-W4A16") model = AutoModelForMultimodalLM.from_pretrained("PixelML/Bonsai-2-27B-W4A16", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PixelML/Bonsai-2-27B-W4A16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PixelML/Bonsai-2-27B-W4A16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PixelML/Bonsai-2-27B-W4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PixelML/Bonsai-2-27B-W4A16
- SGLang
How to use PixelML/Bonsai-2-27B-W4A16 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "PixelML/Bonsai-2-27B-W4A16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PixelML/Bonsai-2-27B-W4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "PixelML/Bonsai-2-27B-W4A16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PixelML/Bonsai-2-27B-W4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use PixelML/Bonsai-2-27B-W4A16 with Docker Model Runner:
docker model run hf.co/PixelML/Bonsai-2-27B-W4A16
Bonsai-2 27B — W4A16 (community conversion)
W4A16 GPTQ conversion of Prism ML's Bonsai-2 27B (the 1.72-bpw ternary retrain of Qwen3.8-27B) into a vLLM-loadable checkpoint, so the weights can run the full vLLM feature set — including native DFlash2 speculative decoding in vLLM ≥ 0.28.0 — outside the llama.cpp-only ternary format. Community conversion, not an official Prism ML release.
| Parameters | 27.36B (24.35B language + 2.54B embed/lm_head + 0.46B vision + MTP module) |
| Checkpoint | 19.5 GB (W4A16 pack-quantized language model; int8 lm_head/embed/MTP; visual tower + MTP in bf16) |
| Context | 262,144 tokens |
| License | Apache 2.0 |
Provenance
The source is the F16.gguf from
prism-ml/Ternary-Bonsai-2-27B-gguf
@ 6ed5e12bf84b7a63069882c91dd9e9218647d17b, whose weights are stored in a
Hadamard-rotated, v-grouped, delta-normed layout for llama.cpp's custom
kernels. Conversion inverts that layout deterministically:
- Hadamard unrotation —
W_hf = W_stored @ blockdiag(H_sylv·diag(s_b)/√1024)per 1024-block of the input dim; signs from the file's ownprism.hadamard.*manifest. - GDN v-layout reorder — the 48 v-heads move from rep-major (3×16) to
group-major (16×3) in
attn_qkv(v segment),attn_gate,ssm_alpha,ssm_beta,ssm_a,ssm_dt,ssm_conv1d(v part) andssm_out(columns), mirroring the Bonsai-demoruntime.pyreorder(). - Delta norms —
attn_norm,post_attention_norm,output_norm,attn_q_norm,attn_k_normare stored asg − 1in the GGUF; restored tog(the runtime adds the 1 inside its fused RMSNorm+rotate kernel). - Grafts —
model.visual.*andmtp.*are absent from the ternary GGUF and are copied verbatim (bf16) from Qwen/Qwen3.8-27B. The MTP module is what DFlash2 speculative decoding drafts with.
Verified: NLL 1.169 on a held-out sentence (base Qwen3.8-27B: 1.518 through the same harness), coherent greedy generation, structural index match.
Quantization
GPTQ W4A16 via llmcompressor 0.13 (pack-quantized compressed-tensors):
256 samples × 1024 tokens of open_platypus, symmetric group-128. Then the
syv-ai single-user prepare chain: int8 (group-128) lm_head, embed_tokens and
MTP module in place, plus the 40960-token draft head
(mtp.draft_lm_head, 213 MB) for DFlash2 speculative decoding. Per-layer
GPTQ round-trip relative errors 0.6–0.8%. The vision tower stays bf16.
Serving
vLLM ≥ 0.28.0 (DFlash2 is native there; no patch needed for the drafter):
vllm serve /path/to/Bonsai-2-27B-W4A16 \
--speculative-config '{"method":"dflash2","method_config":{"draft_tokens":7}}'
or the syv-ai single-user launcher (SPEC=dflash2 CTX=fast), which also
enables lookup-augmented drafting.
Measured on 1× NVIDIA CMP 170HX (SM80, 180 W): 155.7 tok/s single-stream decode (256-token cohort), 251.6 tok/s on a 900-token cohort (adaptive draft depth), prefill 1876 tok/s @ ~6.6k prompt, DFlash2 acceptance 4.17 tokens/draft (59.6% per position) with the base-calibrated drafter at zero recalibration. Full receipts, protocol and the ternary-llama.cpp comparison lane: PixelML/club-170hx PR #49 and #47.
Notes and limitations
- Quality benchmarks are the upstream Bonsai-2 numbers (84.78 thinking-mode average, community-reported) plus GPTQ error on top; no independent eval suite was run for this conversion.
- The checkpoint keeps Qwen3.8-27B's vision tower; the ternary retrain covers the language model only.
mtp.*andmodel.visual.*are required at serve time for DFlash2 and image input respectively — do not strip them.- If you serve the DFlash2 drafter (syvai/Qwen3.8-27B-DFlash2-W4A16), note it was calibrated on the base model's hidden states; acceptance against this retrain measured 59.6% per position with no recalibration.
- Downloads last month
- 318
Model tree for PixelML/Bonsai-2-27B-W4A16
Base model
Qwen/Qwen3.8-27B