TECHNOLOGY

ORT WebGPU: comparing browser and native generation on matching exports

In this article
THE QUICK TAKE

The tested browser and native paths reach near decode parity for several models when generation strategies align; this does not establish universal browser parity or identical startup cost.

A browser-versus-native language-model comparison can accidentally measure different generation loops rather than the browser boundary. The ORT WebGPU benchmark addresses this by using unchanged ONNX exports, saved prompt token IDs and comparable GPU token selection in both paths. Its concrete result is narrower, and more useful, than saying that JavaScript is always faster or slower than C++.

What the harness holds constant

The benchmark definition specifies batch one, greedy generation, suppressed EOS, static KV capacity of 8K, prompt lengths 128/512/1024 and 128 generated tokens. Each point has one warmup and five measured repetitions. The request records hashes of model artifacts and exact input IDs rather than relying only on matching model names.

Both paths can feed the selected token directly back into GPU decoder input. Multiple outstanding readbacks deliver IDs to the CPU in order; they do not represent independent parallel tokens or speculative decoding. Autoregressive dependencies remain. Gemma follows a distinct mixed embedding and CPU-sampling path, so it should not inherit assumptions from the single-graph models.

The timing ends when results are available

First-token timing includes complete prompt processing and the first CPU-readable selected token. Decode excludes that first token and ends only after all remaining output IDs are CPU-readable. Loading, tokenization, warmup and KV reset fall outside the timed request. Rates use mean elapsed duration rather than an average of reciprocal instantaneous speeds.

These choices prevent GPU submission time from masquerading as completed response time. They also mean the experiment cannot answer cold-start latency, memory peaks or ordinary chat behavior with natural stopping. The guide to inference benchmark scope helps separate those questions before comparing numbers.

What the RTX experiment found

The RTX 5080 report compares the same ORT source revision on Windows and D3D12, using an Edge browser build and a source-built Web runtime with JSPI. It verifies complete output agreement for the tested cases. Once native generation uses the comparable GPU feedback strategy, decode differences for Aion, Phi-4-mini and both Qwen models are below 1% in that report.

Gemma remains different. At input length 1024, native decode is 131.75 tokens/s versus 70.93 in Web, a reported 46.2% lower browser rate. That residual cannot be assigned entirely to JavaScript or one kernel without further profiling. Sharing the ORT revision also does not make the browser’s Dawn build, compiler and platform patches identical to the native stack.

Correctness checks can invalidate a speed comparison

A separate Panther Lake comparison evaluates the optimized native harness against the GenAI public API. It excludes Qwen3.5-2B from accepted performance comparisons because generated output differs. A later investigation explains a floating-point strictness difference, but the report keeps the exclusion because no new matched-policy timing experiment was performed.

That is a useful boundary: explaining an output mismatch does not retroactively validate its old speed row. The other results also vary by model and timing phase, so faster decode does not establish faster first output. Preserve the actual runtime hashes, output IDs and complete delivered timing when reproducing the study. The software reproducibility guide explains why these belong together. The evidence supports an attributed implementation experiment, not a ranking of every browser, operating system or ONNX deployment.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles