Goal
Improve token generation throughput (tok/s) and reduce GPU memory waste.
Known Issues
Rust (wgpu) backend: ~30 tok/s vs TS (WebGPU) ~60 tok/s
The Rust oxbitnet crate on the same hardware (RTX 5090) produces ~30 tok/s — half the throughput of the TypeScript/WebGPU path. Needs profiling to identify the bottleneck (dispatch overhead, buffer mapping, pipeline caching, etc.).
Uniform buffer leak
~900+ uniform buffers are created per forward pass and never released or pooled. Each createBuffer call is an IPC round-trip to the GPU process.
Fix: Pool or pre-allocate uniform buffers, reuse across passes.
GGUF file fetched twice
The model file is fetched once for weight loading and again for tokenizer extraction. On a ~700 MB file this doubles download time on first load.
Fix: Parse both weights and tokenizer metadata from a single fetch.
OpenGL ES fallback on Linux + NVIDIA + Wayland
Chrome WebGPU falls back to ANGLE OpenGL ES on this configuration (crbug/442791440), resulting in ~100x slower inference vs Vulkan.
Workaround: Launch Chrome with --ozone-platform=x11 to force X11 mode, which enables Vulkan WebGPU. Not a code fix — document in README/troubleshooting.
Optimization Opportunities
Shader-level
Runtime-level
Rust (wgpu) specific
Measurement
Prior Work
| Phase |
What |
Commit |
| 1–2 |
Buffer pool, pre-allocated uniforms |
d9a9819 |
| 3 |
Bind group caching (decode path) |
1b169c1 |
References
Goal
Improve token generation throughput (tok/s) and reduce GPU memory waste.
Known Issues
Rust (wgpu) backend: ~30 tok/s vs TS (WebGPU) ~60 tok/s
The Rust
oxbitnetcrate on the same hardware (RTX 5090) produces ~30 tok/s — half the throughput of the TypeScript/WebGPU path. Needs profiling to identify the bottleneck (dispatch overhead, buffer mapping, pipeline caching, etc.).Uniform buffer leak
~900+ uniform buffers are created per forward pass and never released or pooled. Each
createBuffercall is an IPC round-trip to the GPU process.Fix: Pool or pre-allocate uniform buffers, reuse across passes.
GGUF file fetched twice
The model file is fetched once for weight loading and again for tokenizer extraction. On a ~700 MB file this doubles download time on first load.
Fix: Parse both weights and tokenizer metadata from a single fetch.
OpenGL ES fallback on Linux + NVIDIA + Wayland
Chrome WebGPU falls back to ANGLE OpenGL ES on this configuration (crbug/442791440), resulting in ~100x slower inference vs Vulkan.
Workaround: Launch Chrome with
--ozone-platform=x11to force X11 mode, which enables Vulkan WebGPU. Not a code fix — document in README/troubleshooting.Optimization Opportunities
Shader-level
vec4/u32x4loads in ternary matmul kernels (currently scalar)Runtime-level
encoder.finish()+queue.submit()calls per tokenRust (wgpu) specific
device.poll()frequency and blocking behaviorMeasurement
--benchmarkflag toexamples/node-cli(fixed prompt, measure prefill + decode tok/s)--benchmarkflag to Rustchatexample for comparisonPrior Work
d9a98191b169c1References