Instructions to use prism-ml/Bonsai-8B-AWQ-4-bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prism-ml/Bonsai-8B-AWQ-4-bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="prism-ml/Bonsai-8B-AWQ-4-bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("prism-ml/Bonsai-8B-AWQ-4-bit") model = AutoModelForCausalLM.from_pretrained("prism-ml/Bonsai-8B-AWQ-4-bit", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use prism-ml/Bonsai-8B-AWQ-4-bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prism-ml/Bonsai-8B-AWQ-4-bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prism-ml/Bonsai-8B-AWQ-4-bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/prism-ml/Bonsai-8B-AWQ-4-bit
- SGLang
How to use prism-ml/Bonsai-8B-AWQ-4-bit 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 "prism-ml/Bonsai-8B-AWQ-4-bit" \ --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": "prism-ml/Bonsai-8B-AWQ-4-bit", "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 "prism-ml/Bonsai-8B-AWQ-4-bit" \ --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": "prism-ml/Bonsai-8B-AWQ-4-bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use prism-ml/Bonsai-8B-AWQ-4-bit with Docker Model Runner:
docker model run hf.co/prism-ml/Bonsai-8B-AWQ-4-bit
Bonsai-8B โ AWQ 4-bit
Summary
This repo provides an AWQ 4-bit checkpoint so you can run Bonsai-8B on sglang (or vLLM) until native 1-bit support lands in those engines. The repack from 1-bit to AWQ 4-bit is lossless. Both formats use group size 128, and Bonsai's binary weights (ยฑd) fit exactly inside AWQ INT4 by an exact conversion formula.
For the best Bonsai experience on edge or consumer-grade hardware, use the native 1-bit releases. The 1-bit format is where Bonsai's memory and energy wins come from.
- Bonsai-8B MLX 1-bit โ 1-bit MLX for Apple Silicon.
- Bonsai-8B-gguf - 1-bit gguf supported by llama.cpp across many backends (GPU, Metal, CPU, Vulkan, etc)
- Bonsai-8B FP16 โ FP16 safetensors for stock HuggingFace tooling.
How It Works
Bonsai weights are ยฑd (binary) with a shared scale across a group size of 128. INT4 can represent these values exactly. Embedding and lm_head stay FP16 due to sglang limitations.
AWQ INT4 dequantization: weight = scale ร (int4 โ zero).
+d โ scale=d, int4=9, zero=8 โ d ร (9-8) = +d
-d โ scale=d, int4=7, zero=8 โ d ร (7-8) = -d
Serve
pip install sglang
python -m sglang.launch_server \
--model /path/to/Bonsai-8B-awq/ \
--port 8000 \
--dtype bfloat16
Use
# Completion API
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{"model":"Bonsai-8B","prompt":"The capital of France is","max_tokens":20}'
# Chat API
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"Bonsai-8B","messages":[{"role":"user","content":"Who are you?"}],"max_tokens":100}'
Multi-GPU (8ร H100)
# Option A: DP=8 โ 8 independent replicas, no inter-GPU comms
python -m sglang.launch_server \
--model /path/to/Bonsai-8B-awq/ \
--dp-size 8 \
--load-balance-method total_tokens \
--port 8000 --dtype bfloat16
# Option B: TP=2 DP=4 โ 4 replicas, each split across 2 GPUs
python -m sglang.launch_server \
--model /path/to/Bonsai-8B-awq/ \
--tp-size 2 --dp-size 4 \
--load-balance-method total_tokens \
--port 8000 --dtype bfloat16
# Option C: TP=4 DP=2 โ 2 replicas across 4 GPUs each
python -m sglang.launch_server \
--model /path/to/Bonsai-8B-awq/ \
--tp-size 4 --dp-size 2 \
--load-balance-method total_tokens \
--port 8000 --dtype bfloat16
Appendix
Launch time
With pre-built sgl-kernel wheels: 15 s. First launch on an arch without pre-built wheels (e.g. L40S / sm_89) takes 3โ5 min while sglang JIT-compiles Marlin GEMM + FlashInfer kernels; artifacts cache to ~/.cache/tvm-ffi/ and ~/.cache/flashinfer/, so subsequent launches drop back to 15 s.
Known-good environment
Example of successful end-to-end serving environment:
sglang[all] == 0.5.9torch == 2.9.1,transformers == 4.57.1,triton == 3.5.1ninja == 1.13onPATHnvccfrom CUDA 12.8 first onPATH(sglang's JIT Marlin needs-std=c++20; CUDA 11.x will fail)- Python 3.12
- Downloads last month
- 316
Model tree for prism-ml/Bonsai-8B-AWQ-4-bit
Base model
prism-ml/Bonsai-8B-unpacked