Section 05 · Inference · measured 2026-11-11
Bonsai 2 4B is PrismML's model. Here it runs on the visitor's own graphics card inside the page: 906 MB of weights, downloaded once and then served from the browser cache. There is no inference server in the path, so once the weights are in the browser's store the answer costs no request to any server. The runtime does knock on this machine over loopback every 4 seconds, looking for a local model node; that probe never leaves the device and is not counted here.
Run it here
This checks what the browser can actually do before it offers to download anything. On a desktop graphics card the button loads the weights and answers on your machine. Where the browser cannot run it, the same panel says which capability is missing and plays the recorded run instead.
Apache-2.0 weights. No account, no key, nothing computed on a server.
Nothing was downloaded.
The panel plays the recorded run instead: real tokens captured from the same model on the reference engine, for the default prompt. A live run continues past the point where the recording stops.
Mechanism
Four steps, in this order. The order is the design: the visitor is told what will be downloaded before a byte moves, and the page learns what the device can do before it promises a model.
The size comes before the download. The button names 906 MB. The runtime then shows its own confirmation; that yes is remembered on this device, so a later visit is not asked again, and the dialog's checkbox only turns on an unattended memory pass. A declined prompt means nothing is fetched.
Byte ranges, kept in the browser's own store. The runtime fetches the weight file in ranges and keeps each range in a persistent browser database keyed by URL and range, because an ordinary HTTP cache refuses a file this size. After the first download a reload is a cache hit, not a refetch. A self-hosted mirror is tried before HuggingFace, but it does not carry this file — the mirror serves Bonsai 1 and Bonsai 2 27B, and answers 404 for Bonsai 2 4B — so this download has one host, and a HuggingFace outage stops the demo.
Ask for the fast card, mirror its limits. The runtime requests a high-performance adapter, then the software one if the first is refused. It copies the adapter's own maxStorageBufferBindingSize, maxBufferSize and workgroup limit onto the device, because a device without them gets WebGPU's 128 MiB default and a single weight tensor exceeds it.
Tokens stream over SSE from a worker. The worker separates a thinking channel from an answer channel. This page shows both, the thinking dimmed, and counts the tokens so the rate on screen is measured rather than asserted.
What the network badge counts. It counts requests this page makes to a server. It does not count the model's own weight fetch, which happens inside the worker, and it does not count the loopback probes the runtime sends to this machine every 4 seconds while it looks for a local model node — those never leave the device, and they are excluded on purpose. So the count is still during generation even while that search runs. During the download, watch the loader's status line, which reports progress when it has a number. Once the weights are in, that line reads ready and the request count stops moving. The line requests since the first token is the one that matters for the claim: it stays at zero while the answer streams.
It is a demonstration, not a proof of the whole machine. Nothing here can see a browser's own background traffic. What it can show is that the page issues no inference request: the answer is produced by the worker, on the graphics card the preflight found.
The model behind the tab
The tab model is deliberately the small one: it has to fit a browser's budget on a desktop card. The model measured below is the big one, on one card in one machine. The numbers below are decode rates from llama.cpp's own report, three runs of 400 tokens each, median quoted.
| Model | Weights | Runtime | Decode, three runs | Median |
|---|---|---|---|---|
| Bonsai 2 27B | PQ2_0 ternary | llama.cpp | 121.6 · 119.9 · 113.9 | 119.9 tok/s |
| Gemma 4 12B | Q4_K_M | llama.cpp | 47.2 · 48.1 · 50.2 | 48.1 tok/s |
One RTX 5090, 32 GB. Prompt: “Explain, in about 300 words, how a hash map handles collisions, covering chaining and open addressing.” Measured 2026-11-11. Each figure is llama.cpp's own per-request report for that run and the median of the three is quoted; the record holds the three run rates and their token counts, and does not record concurrency.
Bonsai 2 27B is 5,946,648,928 bytes in its smallest build and wants about 10 GB of card for the fast build. The 4B is 949,549,920 bytes and fits a desktop browser's budget. The 27B decodes at 119.9 tok/s as a native process on one card; the 4B measured 21–28 tok/s in a browser, roughly four to six times slower. Two sizes, each on the hardware that suits it — and the tab model stays small because in-browser decode is bound by per-layer cost, the layer count rather than the size of the weights: the 4B has 36 layers. The first browser profile blamed kernel-dispatch latency; the correction was that most of the cost was a buffer-pool clear path, and after that fix the forward phase measured 23.9 ms per token on the 1.7B build, down from 116.8.
Degradation is designed in
A page that discovers the visitor's laptop cannot run the model by failing after the download wastes their bandwidth and their trust. Each rung below is checked before a model is offered; the panel falls through to the recorded run and names the rung.
| What the check finds | What the panel does |
|---|---|
| No WebGPU API | Named before the press; the primary button becomes the recorded run |
navigator.gpu exists but no adapter is handed back — asked twice, once for the software rasteriser | Same: the API existing is not an adapter |
| Only a software rasteriser is offered | Same: the runtime warns that on that class of adapter it decodes at well under one token a second, so it is not presented as a demo |
| The largest single buffer is under 128 MiB | Same, with the limit and its value named |
| The host is not on the runtime's allowlist | Same, with the host named |
| Runtime loads, but no first token arrives | The reason is shown and the recorded run plays in the same panel |
Every model is refused on a phone, at any size, because a phone's browser froze the device when asked to hold even the smallest one. The panel says so and points at running the model on the machine instead, over loopback, where there is no tab budget at all. This is a deliberate refusal, not a missing feature.
The replay is 48 tokens recorded from Bonsai 2 4B on the model's reference engine, CPU, for the default prompt — the first of the three 48-token cases in the runtime's parity check, where 48 of 48 tokens agree in this stream and 144 of 144 across all three. It is replayed at 22 tokens a second, the low end of the 21–28 band measured in a browser. The recording stops at 48 tokens because that is what the harness stores per case; a live run continues into the answer.
Provenance
Every figure on this page traces to a measured artifact: the 2026-11-11 recorded benchmark for the 27B decode rates, the browser runtime's own model table for the 906 MB and the 262,144-token context, the reference token recording for the replay, and a browser profiling run for the 21–28 tokens a second. Nothing is estimated. Where a number is a replay, a cap or a derived rate, the sentence next to it says so.
| Bonsai 2 4B weight file | 949,549,920 bytes — the size the runtime prints as 906 MB; PTQ1_0 ternary; Apache-2.0 |
| Bonsai 2 27B smallest build | 5,946,648,928 bytes (PTQ1_0); 7,206,168,928 bytes for the PQ2_0 build the decode run used |
| Decode rates | llama.cpp predicted_per_second, three runs, median; 2026-11-11 |
| Browser decode band | 21–28 tok/s for short prompts, measured on the WebGPU runtime |
| Replay | 48-token case recorded on the upstream reference fork, prism-b12128, CPU; one of three cases, 48/48 agree in this stream and 144/144 across all three |
| Software rasteriser | the WebGPU worker's own software-adapter warning: well under 1 tok/s when the adapter classifies as software |