bench
Skill2 starsChanged 3 months agoMITView on GitHub
Run the benchmark matrix on physical Android and iOS devices and compare against baselines.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- ddalcu/mlx-servetheir own version, first seen Oct 4, 2026
- deevus/skillstheir own version, first seen Aug 7, 2026
- smgglrs-ai/navratheir own version, first seen Jun 29, 2026
- ai-agent-lead/skillstheir own version, first seen Jun 27, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- ddalcu/mlx-serve★ 1.7ksame name
- ai-agent-lead/skills★ 2same name
- deevus/skills★ 2same name
- smgglrs-ai/navra★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- figma-implementSkill
- memory-profileSkill
- review-l10nSkill
- review-prSkill
- run-e2eSkill
- run-pr-e2eSkill
- start-taskSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 5 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 66
When new devices come online, add a row here and a slug for their baseline file.
- Very specific: line 86
Use --skip-build when the APK is already installed and the bench-config script hasn't changed.
- Distinctive: line 120
When invoking through the multi-device pipeline (e.g.
- Very specific: line 136
Default regression threshold is --pct 15.
- Very specific: line 140
Check connected devices: adb devices -l.
- Distinctive: line 152
Run the full tier on the device (use filters only if RAM forces it).
- Very specific: line 161
Every cell has status: 'ok' (or a documented skipped reason).
- Distinctive: line 175
Commit, open a PR to pocketpal-ai.
- Distinctive: line 177
Run on the device under its normal load profile (screen on, typical background apps), not freshly rebooted, so the baseline reflects what …
- Very specific: line 215
Keep the screen on during a full run — Android dozes the e2e flavor under doze, which corrupts cell timing.
- Very specific: line 219
If a full run takes longer than 4 hours, something is wrong — usually thermal throttling or a model file that didn't pre-download.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Benchmark Matrix
You are running the benchmark-matrix pipeline for PocketPal AI.
Input
Request: $ARGUMENTS
What This Pipeline Does
Sweeps (model × quant × backend) cells through llama.rn on a real device, recording prompt-processing tok/s (pp_avg), token-generation tok/s (tg_avg), wall time, peak memory, and the effective backend (cpu / opencl / cpu+opencl-partial / hexagon / cpu+hexagon-partial / metal / cpu+metal-partial / unknown) derived live from native log lines. Compares the resulting report against the device's committed baseline to flag perf regressions or silent backend fallbacks.
Android runs through the WDIO spec or yarn build:bench-config --push below. On a physical iPhone, run yarn bench:ios --device <udid> [--app ../ios/build/PocketPal.ipa] from the app worktree's e2e/ (build with yarn ios:build:ipa; --dry-run first). It drives the same matrix with xcrun devicectl only and pulls, stamps and pass-gates the report itself (e2e/README.md, "iOS (physical iPhone)").
--app replaces the App Store PocketPal (same bundle id ai.pocketpal) and wipes its data. Get the user's explicit OK before installing. Keep the iPhone unlocked and on power, and do not lock it mid-run. iOS baselines are separate from Android ones: merge and compare refuse cross-platform input.
Tiers
Single source of truth: BENCHMARK_FULL_MODELS in e2e/fixtures/benchmark-models.ts. Smaller tiers are derived as id filters from that list.
| Tier | Models × quants × backends | Cells | Runtime | When |
smoke (default) | 3 × 3 × 2 | 18 | ~10–15 min | Regression gate; PR + every llama.rn nightly |
focused | 6 × 6 × 2 | ~60 | ~30–45 min | Investigation when smoke flags something |
full | 11 × 8 × 2 | ~165 | ~3 hr/device | Recalibrating defaults, adding device class |
Pick based on the trigger:
- PR touching inference / native code →
smoke - Smoke regression on one cell →
focusedwithBENCH_MODELS=narrowed to that family - llama.rn upgrade →
smokefirst;fullonly if you intend to refresh the baseline - New device →
fullonce to seed a baseline, thensmokethereafter
Infrastructure
In-app driver (preferred, no WDIO)
BenchmarkRunnerScreen(insrc/__automation__/screens/) runs the matrix entirely in-app.- Reached via deep link:
pocketpal://e2e/benchmark(E2E flavor only). - On-device backend detection:
addNativeLogListenercaptures llama.cpp log lines per cell;src/__automation__/logSignals.tsparses them into aLogSignalsstruct and a 4-stateeffective_backendenum. - Reads
bench-config.jsonfrom the e2e flavor's external files dir. Writesbenchmark-report-<timestamp>.jsonnext to it.
WDIO spec (fallback / CI)
e2e/specs/benchmark-matrix.spec.ts— thin wrapper that triggers the screen via deep link and polls forbench-runner-screen-status="complete". Use when running through the unified E2E pipeline.
Scripts (in e2e/scripts/)
build-bench-config.ts— readsBENCH_TIER+ filters, writesbench-config.json, optional--push <udid>.benchmark-compare.ts— compares two reports row-by-row. Regression trigger:|delta%| > --pct(default 15) on eitherpp_avgortg_avg, oreffective_backendmismatch. Exit 1 on regression.merge-bench-reports.ts— merges raw report glob into a canonical baseline. Dedupes by(model_id, quant, requested_backend), prefersstatus:ok, latest timestamp wins, sorts deterministically, stripslog_signals.raw_matches.
Baselines (in e2e/baselines/benchmark/)
Named <device-slug>.json. (Sibling e2e/baselines/memory/ holds the unrelated memory-profile baselines.) One file per device class; all backends × quants × models live in one report. Current baselines:
poco-myron.json— POCO X9 Pro Myron / Snapdragon 8 Elite Gen 5 / Adreno 840 — tracked
When new devices come online, add a row here and a slug for their baseline file.
Devices & filter mapping
Low-RAM phones cannot run the full quant ladder for every model — heavy combos (phi-4-mini q8_0, gemma-4-e2b q8_0) get OS-killed. Filter with BENCH_MODELS=/BENCH_QUANTS= for those devices instead of letting the matrix OOM mid-run.
| Device ID | UDID | RAM tier | Notes |
poco-myron | df8fc5ef | high (16 GB) | Adreno 840; runs full matrix; canonical GPU device |
pixel-9-real | 45300DLAQ004DH | high (16 GB) | Tensor G4; runs full matrix |
oneplus-6-real | ba5702bf | low (~6 GB) | Skip phi-4-mini and gemma-4-e2b q8_0 cells |
android-emu | emulator-5554 | n/a | Smoke only; no GPU; for spec-shape verification |
Don't change the slug of a tracked baseline without also re-running against the new slug — comparison is filename-keyed.
Builds Required
- Android E2E APK:
yarn android:build:e2e(installs ascom.pocketpalai.e2e, ships the automation bridge). - The
prodflavor has no automation bridge; it cannot run this pipeline.
Use --skip-build when the APK is already installed and the bench-config script hasn't changed.
How to Run
Direct (preferred for ad-hoc runs)
One device at a time. Replace <udid> with the value from e2e/devices.json.
cd <worktree>/e2e
# 1. Generate config + adb push to device
BENCH_TIER=smoke yarn build:bench-config --push <udid>
# (optional filters narrow the chosen tier — they can't widen it)
BENCH_TIER=full BENCH_MODELS=qwen3-1.7b,gemma-3-1b BENCH_QUANTS=q4_0,q6_k \
yarn build:bench-config --push <udid>
# 2. Cold-launch the runner via deep link
adb -s <udid> shell am start -a android.intent.action.VIEW \
-d 'pocketpal://e2e/benchmark' -p com.pocketpalai.e2e
# 3. Tap "Run benchmark matrix" on the screen.
# Wait for the status footer to read "complete".
# Smoke ≈ 10–15 min, full ≈ 3 hr — keep the screen on.
# 4. Pull the report
adb -s <udid> pull \
/sdcard/Android/data/com.pocketpalai.e2e/files/benchmark-report-*.json \
/tmp/bench/<device>/Via the unified E2E runner
When invoking through the multi-device pipeline (e.g. CI):
BENCH_TIER=smoke yarn e2e:android --skip-build \
--spec benchmark-matrix --devices <device-id>Reports land in e2e/reports/<timestamp>/<device-id>/.
Comparing results
npx tsx e2e/scripts/benchmark-compare.ts \
e2e/baselines/benchmark/<device>.json /tmp/bench/<device>/benchmark-report-*.jsonDefault regression threshold is --pct 15. Effective-backend changes are flagged independent of the numeric deltas — a silent OpenCL→CPU fallback is a regression even if the cell got faster.
Typical Workflow
- Check connected devices:
adb devices -l. - Confirm the E2E APK is installed:
adb -s <udid> shell pm list packages com.pocketpalai.e2e. If missing,yarn android:build:e2e. - Pick the tier (see "Tiers" above).
- Per device: generate + push config → deep-link the runner → tap Run → wait for
complete→ adb pull the JSON. - Compare each pulled report against
e2e/baselines/benchmark/<device>.json. - Present results: per-cell deltas, peak memory, effective_backend, PASS/FAIL from the comparison script.
Refreshing a baseline (after llama.rn upgrade, native change, or new device)
Baselines are committed to the pocketpal-ai repo. Refreshing one is a focused task:
/start-task "Refresh bench baseline for <device> (llama.rn <ver>)"— gets a worktree and task branch.- Run the full tier on the device (use filters only if RAM forces it). Capture multiple raw reports if you need to top-up cells the OS killed mid-run — the same model file is cached, so re-runs are fast.
cd worktrees/TASK-xxx/e2e BENCH_TIER=full yarn build:bench-config --push <udid> adb -s <udid> shell am start -a android.intent.action.VIEW \ -d 'pocketpal://e2e/benchmark' -p com.pocketpalai.e2e # … wait for complete, pull, then top-up missing cells with BENCH_QUANTS= - Sanity-check the raw reports:
- Every cell has
status: 'ok'(or a documentedskippedreason). - GPU cells show
effective_backend: 'opencl'; CPU cells show'cpu'. Any'unknown'on a non-GPU device means the parser missed a log line — investigate before merging. - Per-cell
pp_avg/tg_avgwithin ~10% of the prior baseline (modulo the change you're absorbing).
- Every cell has
- Merge into a canonical baseline:
npx tsx scripts/merge-bench-reports.ts \ --input '/tmp/bench/<device>/benchmark-report-*.json' \ --out baselines/benchmark/<device>.json \ --device '<full device label>' \ --soc '<soc + gpu>' \ --commit "$(git rev-parse --short HEAD)" \ --llama-rn-version "$(node -p 'require(\"../package.json\").dependencies[\"llama.rn\"]')" \ --drop-models <stale-model-id-if-any> - Commit, open a PR to pocketpal-ai. Include a one-paragraph summary of why the baseline shifted (llama.rn version, native change, device, etc.).
Run on the device under its normal load profile (screen on, typical background apps), not freshly rebooted, so the baseline reflects what users actually see.
Heavy-model OS-kill pattern
phi-4-mini and gemma-4-e2b at q8_0 get OS-killed mid-init on most phones. The matrix is ordered to put heavy combos last so partial-row data from earlier cells survives in the JSON report. After the main run finishes (or gets killed), top-up the missing cells:
BENCH_TIER=full BENCH_MODELS=phi-4-mini BENCH_QUANTS=q8_0 \
yarn build:bench-config --push <udid>
# … re-run the deep link, pull a second report, merge both via merge-bench-reportsThe model file is cached on disk, so the top-up runs in minutes.
Effective backend — what unknown means
effective_backend is derived from native log lines captured during context init (deriveEffectiveBackend in src/__automation__/logSignals.ts). The states:
cpu— no GPU or NPU weight buffer; everything ran on CPU as requested. The iOS simulator lands here (0 layers offloaded).opencl— OpenCL init succeeded, all layers offloaded to GPU.cpu+opencl-partial— OpenCL initialized but some layers stayed on CPU (large-buffer regression, partial offload).hexagon/cpu+hexagon-partial— weights on anHTP*buffer, fully or partially offloaded.metal/cpu+metal-partial— weights on anMTL*buffer (iOS), fully or partially offloaded.unknown— logs were captured but the parser couldn't classify them. Treat as a real signal: either the log format changed (new llama.rn version) or no logs were captured (init crashed before the listener attached). Investigate; don't merge into a baseline.
A GPU cell reporting cpu is a silent fallback — the comparison script flags this as a regression independent of pp/tg deltas.
Presenting Results
Per device, a per-cell table:
| Model | Quant | Backend | Baseline pp/tg | Current pp/tg | Δpp% | Δtg% | Effective | Status |
Plus the comparison script's PASS/FAIL summary and a one-line note on the worst regression and the worst improvement.
Notes
- Keep the screen on during a
fullrun — Android dozes the e2e flavor under doze, which corrupts cell timing. - A cell with
status: 'failed'and areasonfield is benign (skipped quant, missing download); a cell withstatus: 'failed'and anerrorfield is a real failure. bench-config.jsonlives in the device's external files dir; surviving across uninstalls only if you reinstall the samee2eflavor. Re-push after every fresh APK install.- The merge script's
--drop-modelsflag exists for fixture-renames (e.g.lfm2-1.2b→lfm2.5-1.2b-instruct); use it instead of hand-editing the merged JSON. - If a
fullrun takes longer than 4 hours, something is wrong — usually thermal throttling or a model file that didn't pre-download. Stop and investigate rather than waiting it out.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

