Repository navigation
WebGPU spike: can the browser engine use the GPU? - #52
Conversation
There was a problem hiding this comment.
This spike adds a self-contained spikes/webgpu/ experiment that measures whether the browser engine can reach the GPU via WebGPU. It ships two harnesses — a candle wgpu fork (wgpu-candle) and wllama — plus a candle CPU wasm baseline, with a shared Cache Storage loader, a static dev server, a Playwright driver, a per-process RSS/time guard (added after a 49 GB Chrome OOM), CI fetch/bench scripts, and a report.mjs aggregator that compares generated tokens/text against the native CPU reference. The SHA-256 pinning of the model is good, and the guard is the right response to the earlier runaway allocation. Two issues worth addressing before relying on the wllama cell and the correctness reference.
Automated review by siGit Code Review · commit e18d853 · see the review dashboard
e18d853 to
c377def
Compare
|
siGit Code Review couldn't finish this review: the model's reply could not be read. Mention @sigit-code-review to try again. Automated review by siGit Code Review · commit c377def · see the review dashboard |
c377def to
93d9881
Compare
|
siGit Code Review couldn't finish this review: the model service was unavailable. Mention @sigit-code-review to try again. Automated review by siGit Code Review · commit 93d9881 · see the review dashboard |
|
This change's diff (57 changed files) is over the size budget for an automated review, so siGit Code skipped it. Splitting the change into smaller changes will get each part a review. Automated review by siGit Code Review · commit 20a8139 · see the review dashboard |
|
This change's diff (61 changed files) is over the size budget for an automated review, so siGit Code skipped it. Splitting the change into smaller changes will get each part a review. Automated review by siGit Code Review · commit eb45e2c · see the review dashboard |
eb45e2c to
93d9881
Compare
93d9881 to
8723e3c
Compare
There was a problem hiding this comment.
The spike adds three benchmark harnesses under spikes/webgpu/ — a candle CPU wasm baseline, a candle-wgpu (FerrisMind fork) harness, and a wllama (llama.cpp WebGPU) harness — plus the CI plumbing to run them: a model fetcher with SHA-256 pinning, a static server, a Playwright driver with an RSS/time guard born from the 2026-11-17 laptop panic, per-cell and native bench scripts, and a report aggregator. The earlier tokenizer-checksum finding is addressed (fetch-model.sh now pins and verifies tokenizer.json), and the wllama node_modules import is covered by the workflow's out-of-band install, so those threads are closed. The remaining issues are in the driver/report path: the run-page.mjs comment about not awaiting __start is wrong for wllama (Playwright awaits the returned promise), and the error paths drop window.__partial, which report.mjs relies on for GPU-event reporting of exactly the failing cells the spike cares about.
Automated review by siGit Code Review · commit 93d9881 · see the review dashboard
There was a problem hiding this comment.
This spike adds a full WebGPU evaluation harness under spikes/webgpu/, including two browser harnesses (candle-wgpu and wllama), a CPU baseline, benchmarking scripts, and a CI workflow that runs on GitHub-hosted runners. The spike is fully isolated from product code, with all dependencies and results local to the spike directory. The model and tokenizer are SHA-checked, and the harnesses all use the same Cache Storage entry for model bytes. The workflow builds, runs, and benchmarks each path, and the results are summarized in findings.md and a markdown table. Previous findings about missing tokenizer checks and out-of-band npm installs are addressed in the current diff.
Automated review by siGit Code Review · commit 8723e3c · see the review dashboard
Adds the cpu-baseline and wgpu-candle browser harnesses, the fork patch, the earlier local M4 results (labeled as pre-incident) and a workflow that builds and benchmarks on macos-26 and ubuntu-latest. wgpu-candle now awaits synchronize_async() after load, every prefill chunk and every decode token, so the fork can free in-flight buffers on wasm. guard.mjs watches every descendant of the driver, kills the browser past 4 GB per process or the time limit, and records peak RSS in the result. The model comes from HF in CI (SHA-256 checked, cached); serve.mjs reads it from MODEL_DIR, and the fork path deps are relative to a sibling checkout instead of an absolute home path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
With one match, pattern downloads put the files straight into artifacts/, so report.mjs found no native-* directory: the first run's table had no native rows and every token comparison said "no ref". Give the artifact its own path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
…meout The Chrome wgpu cell on macos-26 was cancelled at the 20-minute job timeout right after its bench rung lost the device, so the rest of the run was never recorded. The rung caps add up to 26 minutes, so the browser job now allows 35. run() takes a drain_every argument (the page reads ?drain=N, the native bench reads DRAIN_EVERY). The matrix adds wgpu-candle cells on macos-26 with drain 8 and 32 to show what the per-token drain costs in decode speed; the guard still caps memory. worker.js hooks GPUAdapter.requestDevice to record device.lost and uncaptured errors, and report.mjs lists them per cell, because the Rust side only surfaces "batch failed validation". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
wllama 3.13.0 (llama.cpp compiled to wasm, with its WebGPU backend) reads the same GGUF from the same Cache Storage entry and runs through the same browser matrix: macos-26 Chrome and WebKit, ubuntu Chrome, plus n_gpu_layers=0 cells as its own CPU path. CI installs it from npm at the pinned version; its wasm is fetched from jsDelivr at that version, because the npm package does not ship it. wllama exposes streamed text, not token ids, so report.mjs compares its output with native CPU on the first 60 characters. run-cell.sh takes an extra query string, serves wllama with cross-origin isolation, and run-page.mjs no longer awaits the page's start hook. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.6.6-acp <noreply@sigit.si>
fetch-model.sh checked the model hash but only printed the tokenizer's, so a republished tokenizer.json would have changed the token-match reference without failing the job. It now checks the hash that all 22 downloads in runs 44087888201 and 44142779991 printed, and removes the file on a mismatch. findings.md lists the pin. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
8723e3c to
edb5ac1
Compare
actionlint has been failing the branch's "Lint workflows" check on them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
The spike is finished and its results are recorded in findings.md. The matrix is 15 cells on hosted macOS runners, and two of them fail by design, so running it on every push to the branch only left each new head red. workflow_dispatch stays for anyone who wants to rerun it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.3 <noreply@ondeinference.com>
There was a problem hiding this comment.
Small follow-up to the WebGPU spike workflow since the last review: the push trigger for spike/webgpu is removed so the matrix now runs only via workflow_dispatch (the added comment explains why — two cells fail by design and every push went red), the stage listing switches from ls -lR | head to find, and the wllama npm spec gets quoted. All three earlier threads (package.json dependency, tokenizer checksum, run-page await semantics, native_bench usage string) are addressed or settled and nothing here reopens them. The trigger removal is intentional and documented; the find replacement is fine under GitHub Actions' default bash -e (no pipefail, so a SIGPIPE from head can't fail the step).
Automated review by siGit Code Review · commit f53faca · changes since edb5ac1 · see the review dashboard
This is a spike, not a feature to ship. It records whether onde's browser engine can use the GPU through WebGPU instead of running candle on the CPU (wasm simd128, single-threaded, as in #50). Everything lives under
spikes/webgpu/and does not touch the product crates.Stacked on #50 (base
feature/web-engine) so the diff shows only the spike files.What's here
webgpu-spike.yml) that builds the wasm, downloads and caches the model, and benchmarks every path onmacos-26andubuntu-latest. It runs only onworkflow_dispatchand on pushes tospike/webgpu, so normal CI is untouched.findings.mdwith the full results table, the pinned versions, the fork patches, and a recommendation.Everything ran on GitHub-hosted runners. Local GPU runs panicked the laptop three times (Chrome exhausted 50 GB on a 24 GB machine), which is written up in
findings.md.Results
wllama with GPU offload was roughly 250x faster at prefill and 5x faster at decode than the current CPU path on the
macos-26runner. But its output did not match the CPU reference on that runner's paravirtual GPU. The native Metal path differed from native CPU on the same VM too, so this may be a VM artifact rather than a real bug.Recommendation
Pursue wllama, park the candle wgpu fork. The next step is a run on real Apple Silicon to settle the correctness question, tracked in #51.