# local-first model latency & capability bench

- Status: `experiment`
- Track: [local compute, .wat compilation & on-device inference](https://aifoc.us/labs/local-compute/)
- Layer: 5. Local Compute, Wasm & Zero-Framework UI
- Updated: 1 December 2026
- Live demo: https://local-first-model-bench.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/local-first-model-bench

## Inspired by

- [what falling ai model latency means for the web](https://aifoc.us/latency/)
- [on-device ai needs a trust model](https://aifoc.us/on-device/)

## Hypothesis

- **Claim:** Running lightweight workloads directly on client WebAssembly, WebGPU, or Chrome Built-in AI (`LanguageModel`/`Summarizer`) beats edge round-trips on tail interactivity once shader warm-up and cold-load bytes are accounted for.
- **Confirms it:** Standardized workloads report warm client latency below `/api/edge-baseline` round-trip times on capable adapters while exporting reproducible client hardware capability profiles.
- **Falsifies or bounds it:** Cold weight/shader warm-up latency or weak client GPUs erase local wins relative to fast streaming edge models.

> **Why this exists:** Debates over "run inference in the browser vs. call the cloud" usually trade anecdotes instead of numbers on the hardware visitors actually own. Measuring real WebGPU, WebNN, Chrome Built-in AI (`Summarizer`/`LanguageModel`), compiled WebAssembly, and round-trip Edge Worker latency on the exact same workload reveals when local execution wins and when network round-trips dominate.


## What this lab tests

[Local-First Model Bench](https://local-first-model-bench.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/local-first-model-bench)) probes [`WebGPU`](https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API), `WebNN`, built-in `LanguageModel`/`Summarizer`, and WebAssembly, racing standardized scoring workloads locally against a Cloudflare Worker `/api/edge-baseline` endpoint.


## Open questions to iterate on

- Where does cold-start + adapter warm-up cross over against streamed edge inference tokens for short vs. long inputs?
- How consistently can feature detection route gracefully from WebGPU/Built-in AI down to compiled Wasm and Edge fallback?

## Iteration log

- **2026-12-01:** Built hardware capability probe (`WebGPU`, `WebNN`, `LanguageModel`, `Summarizer`, Wasm) racing local compute against Worker `/api/edge-baseline`.
- **2026-12-01:** Reordered benchmark harness above setup docs, added Wasm and WebGPU cold setup latency tracking plus accurate edge-faster verdicts, integrated CSP-safe WGSL/JS/JSON DOM syntax highlighting, tightened 700px embed responsiveness, and routed static assets through the Worker with `Cache-Control: no-cache`.

## Primitives tested

- `WebGPU`
- `WebNN`
- `Prompt LanguageModel API`
- `Summarizer API`
- `WebAssembly`
- `Performance Timing`

## Connected labs in other tracks

- [live .wat-to-.wasm compiler & equivalence gate](https://aifoc.us/labs/local-compute/zero-js-wat-web/) — Compiles lightweight zero-dependency Wasm routines cleanly on client CPU.
- [model-gap live conformance probe](https://aifoc.us/labs/platform-observability/model-gap-live-harness/) — Probes broader browser API support across model cutoffs.

---
Canonical: https://aifoc.us/labs/local-compute/local-first-model-bench/
