danyalmalik/Ternary-Bonsai-2-4B-ONNX-WebGPU
prism-ml/Ternary-Bonsai-2-4B-gguf (PrismML's Ternary Bonsai 2, built from Qwen/Qwen3.5-4B) converted to ONNX for running in a web browser with ONNX Runtime Web's WebGPU backend, as used by Quick Inference. Text only: the vision tower is not included.
Created using Bonsai by Prism ML.
Changes from the original
- The graph is the Qwen3.5 ONNX graph of onnx-community/Qwen3.5-4B-ONNX, with every weight
replaced by Bonsai's from
Ternary-Bonsai-2-4B-PQ2_0.gguf. - The ternary matrices (−1, 0 or +1 times a float16 scale per 128 weights) are stored as 2-bit
MatMulNBitswith the same values: the weights are exact. - Bonsai stores its matrices in a rotated basis (a blockwise Walsh–Hadamard transform with sign vectors); the graph
applies the matching transform to each layer's input, as PrismML's runtime does. The token embeddings are a 4-bit
GatherBlockQuantizedof the same ternary values followed by the inverse transform. - The linear attention's alpha and beta projections (float32 in the GGUF) are float16 here.
These are modified files. Checked against PrismML's MLX runtime: on a test prompt the last position's logits agree to a cosine similarity of 0.99999 (same top tokens).
Licence
Apache 2.0, as the original: see LICENSE and NOTICE.txt.
Files
LICENSENOTICE.txtconfig.jsononnx/decoder_model_merged_q2f16.onnxonnx/decoder_model_merged_q2f16.onnx_dataonnx/embed_tokens_q2f16.onnxonnx/embed_tokens_q2f16.onnx_datatokenizer.json