You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comparative benchmark harness that runs a 4-bit quantized LLM entirely in the browser via WebGPU alongside cloud-hosted LLMs, measuring latency, throughput, memory footprint, and output quality across a fixed viability workload of 16 prompts.
Quick Start
# 1. Clone and install
git clone https://github.com/Haadesx/WebGPU_AI.git &&cd WebGPU_AI
cp .env.example .env # ← add your API key
npm install
# 2. Start the backend (proxies cloud API calls)
npm run server # http://localhost:3001# 3. Start the frontend (in another terminal)
npm run dev # http://localhost:5173
Generation settings: temperature=0, top_p=1, with per-prompt max_new_tokens caps of 16-112 tokens to keep runs short.
Full Prompt List
All prompts are stored in benchmarks/workload.json and copied to apps/web/public/workload.json for browser access. The current set is intentionally compact: most prompts are short objective tasks with regex/JSON/numeric scoring, plus three capped subjective prompts for summarization and reasoning quality.
Metrics Collected
Metric
Description
TTFT (ms)
Time from prompt submission to first generated token
True GPU VRAM usage is not accessible from the browser. We collect:
JS heap size via performance.memory (Chrome-only, best effort)
Model artifact size (sum of downloaded model files, reported by WebLLM)
Any internal memory stats reported by the WebLLM engine
These are approximations — see the report template for details.
Understanding the Benchmark Results (Field-by-Field Glossary)
When you export results (JSON or CSV), every record contains the fields below. Here is what each one means, why it matters, and how to interpret it.
Per-Prompt Result Fields
Field
Type
What It Means
promptId
string
Unique ID of the workload prompt (e.g. math_01, summarize_01). Maps back to benchmarks/workload.json.
system
string
Which system produced this result: edge (in-browser WebGPU), cloud_small, or cloud_large.
model
string
Human-readable model name (e.g. "Edge (WebGPU)", "Cloud Small").
output
string
The raw text the model generated. This is the full, unedited response.
timestamp
ISO string
When this specific inference call completed.
Latency & Throughput Metrics
Field
Unit
What It Means
Why It Matters
ttft_ms
milliseconds
Time To First Token — the time between sending the prompt and receiving the very first token of the response.
Measures perceived responsiveness. A low TTFT means the user sees output start almost instantly. Edge models typically have consistent TTFT (~700ms) because everything runs locally. Cloud models can have high TTFT due to network latency, queuing, or (for reasoning models) hidden "thinking" time.
tps
tokens/sec
Tokens Per Second — how fast the model generates tokens after the first token arrives. Calculated as tokens_generated / (total_latency - ttft).
Measures generation throughput. Higher = faster to complete long responses. Cloud models often have higher TPS because they run on powerful server GPUs. Edge models are limited by your local GPU.
total_latency_ms
milliseconds
Total Latency — wall-clock time from prompt submission to the last token received. Equal to ttft_ms + (tokens_generated / tps × 1000).
The end-to-end time the user waits for a complete answer.
Token Counts
Field
Unit
What It Means
tokens_generated
count
Number of output tokens the model produced. For cloud models this comes from the API's usage.completion_tokens. For edge, it's counted from the streaming chunks.
tokens_generated_whitespace
count
Approximate token count estimated by splitting the output on whitespace. Used as a fallback when API usage data is unavailable.
prompt_tokens
count
Number of tokens in the input prompt. From the API's usage.prompt_tokens for cloud; estimated for edge.
Memory Metrics
Field
Unit
What It Means
memory_js_heap_mb
MB
JavaScript heap memory usage at the time of inference, measured via performance.memory.usedJSHeapSize. Only available in Chromium browsers. Shows 0 in Safari or Firefox. This is not GPU/VRAM — it's CPU-side JS memory.
model_size_mb
MB
Estimated size of the model files downloaded for edge inference (e.g. 4309 MB for Llama 3.1 8B 4-bit). Always 0 for cloud models since nothing is downloaded locally. This is the closest proxy we have for VRAM usage, since browsers don't expose GPU memory APIs.
Quality Scoring
Field
Type
What It Means
quality_score
0.0–1.0
The final quality score for this prompt. 1.0 = perfect, 0.0 = failed. For objective prompts, this is binary (0 or 1). For subjective prompts, it's averaged from judge scores.
scoring_details
object
Breakdown of how the score was calculated (see below).
scoring_details.method
string
Which scoring method was used — one of: exact, numeric_tolerance, json_schema, regex, judge, embedding+judge.
scoring_details.objective_score
0 or 1
For objective prompts: did the model's output match the expected answer?
scoring_details.raw_expected
object
The expected answer from the workload (e.g. {"value": 482} or {"regex": "^pattern$"}).
scoring_details.raw_output
string
The model's full output that was evaluated against the expected value.
Scoring Methods Explained
Method
How It Works
Example
exact
Trims whitespace from the output and compares character-by-character to the expected value. Case-sensitive.
Prompt: "Return the 3rd word." Expected: browsers. Output must be exactly browsers — not Browsers or browsers.
numeric_tolerance
Extracts the last number found in the output and checks if it's within ±1% of the expected number.
Expected: 482. If output contains "the answer is 482", it extracts 482 and passes.
json_schema
Parses the output as JSON, then does a deep equality check against the expected JSON object. Order of object keys doesn't matter; array order does.
Expected: {"a":2,"b":[1,2,3]}. Output must parse to the same structure.
regex
Tests the trimmed output against one or more regex patterns. The entire output must match (anchored).
Expected regex: ^s\.toLowerCase\(\);?$. Output s.toLowerCase() passes; Use s.toLowerCase() fails.
judge
Sends the prompt + output to a "judge" LLM which scores correctness (0-1), instruction following (0-1), and clarity (0-1). Final score = average of the three.
Viability Score Index — a presentation-friendly score for whether a model is practical: good answers matter most, but low first-token latency and usable throughput also count.
Device Metadata
Field
What It Contains
device.userAgent
Browser's user agent string (identifies browser, OS, version)
device.platform
OS platform (e.g. MacIntel, Win32, Linux x86_64)
device.webgpuAdapter
GPU adapter name reported by WebGPU (e.g. apple, NVIDIA GeForce RTX 4090)
device.webgpuSupported
Whether WebGPU was detected (true/false)
device.timestamp
When device info was collected
Generation Settings
Field
What It Means
generation_settings.temperature
Controls randomness. 0 = deterministic (always pick the most likely token). Higher = more creative/random. We use 0 for reproducibility.
generation_settings.top_p
Nucleus sampling threshold. 1 = consider all tokens. Lower = only consider the most probable tokens. We use 1 (no filtering).
generation_settings.max_new_tokens
Maximum number of tokens the model is allowed to generate. The compact workload sets short per-prompt caps for faster runs.
Quality Evaluation
Objective Prompts
Scoring
Logic
exact
Trimmed/final-answer string match after stripping common reasoning blocks
numeric_tolerance
Parse number, compare with tolerance
json_schema
Parse JSON, deep-equal (order-insensitive for objects/arrays)
regex
Case-insensitive regex against cleaned output; arrays can require any or all patterns
Subjective Prompts
Scoring
Logic
judge
Cloud Large as judge: correctness + instruction_following + clarity → avg