Skip to content

Unsloth Studio / Desktop: add an Evals tab to Benchmarks that scores a GGUF with lm-eval-harness - #12521

Open
LeoBorcherding wants to merge 180 commits into
unslothai:mainfrom
LeoBorcherding:studio-benchmarks-quality
Open

LeoBorcherding wants to merge 180 commits into
unslothai:mainfrom
LeoBorcherding:studio-benchmarks-quality

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Adds Evals to the Benchmarks page: run any lm-evaluation-harness task against a GGUF through Unsloth Studio's own llama-server and compare scores across models and quants. MMLU, MMLU-Pro, HellaSwag, ARC-Challenge, GSM8K and TruthfulQA are listed first; every other lm-eval task is searchable. Scoring is lm-eval's own.

Stacked on #11808 (Benchmarks page, config sweeps). Until that lands, this diff includes its commits. Phase 3 of #11646.

Original work by @dotVansh (LeoBorcherding#82), plus his sampling fix from LeoBorcherding#595; styling, integration and the fixes below on top.

What it does

  • Backend (routes/benchmark.py, core/benchmark/): runs lm_eval with the gguf backend (gguf: support modern llama.cpp logprobs format (fixes #1437) EleutherAI/lm-evaluation-harness#4012), so it talks to the local llama-server and scores with exact teacher-forced loglikelihoods instead of resolving an HF tokenizer. API under /api/benchmarks/evals; runs and per-sample results in their own eval_runs / eval_samples tables.
  • /v1/tokenize passthrough for the harness, through _LlamaUpstream like the other llama-server routes, so it carries the server's key and gets one respawn if llama-server dies mid-run.
  • Neutral sampling. /v1/completions fills any sampling field a request leaves out from the model's chat recommendations, and the harness leaves them out. Evals now send presence/frequency penalty 0, repeat_penalty 1, top_p 1, top_k 0, min_p 0 unless the task sets them. Without this, Qwen3.5 ran gsm8k with presence_penalty 1.5.
  • lm_eval is pinned to ad8737ae7f, the first commit with the gguf backend; no release has it yet. If it's missing, /run answers 400 with the install command.
  • UI: setup column, live run card with progress, ETA and Show log, a scoreboard (latest score per model and quant per task, 0 to 100 with stderr whiskers), History with compare and graph dialogs.
  • Built from the same components as Config sweeps: the scoreboard and the comparison graph draw with the shared bar chart (features/benchmarks/components/bar-chart.tsx, pulled out of the sweeps chart), the tiles are the shared stat-tile.tsx, and the live log is a shared components/log-pane.tsx that matches Settings > Logs in light and dark. The matplotlib graph is kept only as a "Styled PNG export" download.
  • Strings in all locales.

How it looks

Unsloth Studio (web) on a Colab T4, Llama-3.2-1B-Instruct Q4_K_M and Q8_0, at bb79649781.

live run with the log

Scoreboard, two quants of one model:

scoreboard

Task search, unlisted task Live run, light
History compare Graph dialog

Scores

Colab T4, through /run unless noted; ± is lm_eval's stderr.

model task docs score
Llama-3.2-1B Q4_K_M copa 100 0.77 ± 0.042
Llama-3.2-1B Q4_K_M arc_challenge 1172 acc 0.347, acc_norm 0.374 (± 0.014)
Llama-3.2-1B Q4_K_M gsm8k, 5-shot 1319 strict 0.320, flexible 0.317 (± 0.013)
Llama-3.2-1B Q4_K_M mmlu_high_school_psychology 545 0.613 ± 0.021
Llama-3.2-1B Q4_K_M hellaswag (200-doc limit, same client) 200 acc_norm 0.595 ± 0.035
Llama-3.2-1B Q4_K_M truthfulqa_mc2 (200-doc limit, same client) 200 0.437 ± 0.030
Llama-3.2-1B Q8_0 copa 100 0.76 ± 0.043
Qwen3-4B Q4_K_M copa / mmlu_college_biology 100 / 144 0.81 / 0.813

Repeat runs aren't bit-identical (copa 0.75 to 0.77 on the same model): four slots share one KV cache, so batch composition moves the float math.

Known gaps

  • Vision GGUFs can't run multiple-choice tasks. With a vision projector loaded, llama-server rejects the token-ID prompts scoring needs (400), and the run ends with a generic error. Generation tasks run.
  • A crash in the ~5 s respawn window can still fail a run on the pinned harness: in-flight requests recover, but a new request in the window gets a 503 and the pinned harness only retries 3 times at 5 s. 4 of 5 crash runs finished. gguf: support authentication, honour gen_kwargs, and improve retries EleutherAI/lm-evaluation-harness#4457 (exponential backoff) finished 5 of 5.
  • Stop drains in about 30 s on the pinned harness (the worker exits once its requests 401 after the run's key is revoked, 3 × 5 s each). With Intel videocard compatibility #4457 it took 0.57 s.
  • No sample limit in the UI or API, so hellaswag and truthfulqa_mc2 in full take hours on a small GPU.
  • lm_eval isn't installed by setup; the route tells you how.

Hardware coverage

No hosted GitHub runner has a GPU. The Strix Halo runner on ooba's fork doesn't run Unsloth Studio, so this table is the test report.

Machine Commit What ran
Colab T4 15 GB, Linux, driver 580.82.07, llama.cpp b11876, llama-server API key on, lm_eval ad8737ae7f 30135ad424 7 tasks, 3 models, 2 quants; neutral sampling read off llama-server's /slots; tokenize auth; llama-server killed mid-eval ×5; Stop and the 409s; every UI view in light and dark at 1024 to 1920
Colab T4, earlier 87bb5bad2 copa on Qwen3-4B (found the tokenize 401)

Not run: AMD, Windows, macOS, Unsloth Desktop.

Tests

Measured at 6ff267104d (up to date with main), macOS, Apple M5: frontend typecheck, npm test 0 fail, build, bundle:check, i18n:check:strict; backend test_benchmark_evals.py, test_benchmark_parse.py, test_benchmark_runs.py, test_llama_server_api_key_default.py pass. On the T4 at 30135ad424: the same backend set, 47 passed.

Full results with logs: LeoBorcherding#136 (comment 6456810510).

LeoBorcherding and others added 30 commits September 22, 2026 23:58
…nd parallel-slot sweeps

Reloads the loaded GGUF once per setting, streams timed completions and keeps
llama-server's own timings. Rows that Studio fell back on are skipped with the
reason instead of charted. Prompts rotate across runs so the ngram cache can't
inflate its rows by copying a repeated answer. Phase 1 of unslothai#11646.
…ng and a setup side panel

Runs are saved as they go in two new studio.db tables (benchmark_runs,
benchmark_results) behind /api/benchmarks/runs, so a stopped or crashed
sweep keeps the rows it finished.

Auto-tune tries off, MTP 1-4, ngram and MTP + ngram, picks the fastest
(a simpler setting within 3% wins) and applies it to chat's Run Settings.
A DSpark tuning sweep covers draft depth and draft KV dtype.

Rows are bounded so an out-of-VRAM spill cannot freeze the machine: load
and generation time limits, a throughput floor, OOM labelling, and larger
context rows skipped after the first OOM.

Generations use chat's sampling settings. The chart footer and exports
list every Run Settings value plus GPU, backend, runtime, OS, threads and
RAM. The page is one screen: a setup side panel, the model strip, and the
results, with the live queue drawn as placeholder rows in the chart.
…s a RAM offload sweep

- Benchmark and History tabs. Setup, results and a Train-style run preview share the
  Benchmark tab; History is a card grid with each run's winner, speed-up and row bars.
- Chat's model picker in the tab bar: benchmark any on-device GGUF and quant, loaded
  first with chat's Run Settings. The picked quant now reaches the load and Apply to chat.
- RAM offload sweep: Studio's fit, then MoE expert layers on CPU from all to none
  (n_cpu_moe, scaled to the model's MoE layer count), GPU layer steps for dense models.
  Rows pin 8K context, run from least VRAM to most, and skip hungrier rows after an OOM.
  VRAM after each load is recorded and shown in the table.
- Header shows every GPU, VRAM and RAM used/total, CPU threads and the llama.cpp backend.
- The setup card fits the window and scrolls its Compare list instead of running off it.
- The chart stops growing past its natural width; queued rows draw as quiet lanes.
- The runs list carries each row's mean tok/s so History needs no per-run fetch.
- Number fields clamp when you leave them, not on every keystroke, so clearing one
  to type a new value no longer snaps it to the minimum.
- The Fastest tile names the baseline when nothing beats it (an offload sweep's Studio
  fit); the ratio tile says "nothing beat it" instead of a bare 0.04x.
- A sweep with one family (offload, KV, context) lists its rows flat; single-row
  families (DSpark, DFlash) keep their full names.
- Footer and History show the context rows actually ran at (8K pinned, or "varied").
- History marks a run cut short by Stop as "Stopped early", not "Complete".
- "vs Studio auto" keeps its capital; only "speculation off" reads lowercase mid-sentence.
- Table cells no longer wrap; tighter padding so all eight columns fit.
…and context limit for picked models

- Benchmark runs that select a different GGUF via tuneModel left chat pointed at the benchmark target after finishing. The Restore-after option now reloads the model chat originally had open.
- With prompt rotation on, each swept variant was fed a different subset of the built-in prompts, so a throughput difference could come from prompt length rather than the setting. Every variant now runs the same prompt sequence.
- In context and offload sweeps, one unrelated generation error (e.g. a transient 500) marked the row as out-of-memory and skipped all remaining valid sizes/placements. Only genuine memory/limit/floor failures now trigger that skip.
- When benchmarking a GGUF other than the one loaded in chat, the context-length sweep used the resident model's context window. It now uses the selected model's own context length from its GGUF header.
…nal-save race

- Auto-tune's verdict card would label a cancelled run "Auto-tune picked" and let you apply a winner chosen from partial data, because it keyed off `finishedAt`, which the runner sets even on cancel. It now also requires every row to have reached an end (`ranToEnd`), matching the history grid.
- The first measured sample was counted twice in the live chart and mid-run snapshots because the live run shared its results array with the runner, which had already pushed that sample before emitting it. The live run now copies the array on start so each sample is appended once.
- A slow or in-flight mid-run save could complete after the final save and overwrite the finished benchmark run with a partial snapshot (`finishedAt: null`, fewer rows). The final save now drains any queued checkpoint save first, so it is always the last write.
…r an auto OOM, and skip the relative spill floor during warm-ups

- A Stop during the benchmark's initial model load (or metadata read) left Chat on the benchmark target model even with "Restore chat's settings after" enabled, because the swap happened outside the restore scope. The swap and setup now run inside that scope, and a swap-in-progress is tracked so an aborted load is still restored.
- When the offload sweep's automatic "Studio auto" row ran out of memory, every manual CPU-offload/GPU-layer row after it was wrongly skipped as a context failure, so the lower-VRAM placements the sweep exists to test never ran. Only context sweeps now mark a context as failed; offload rows recover from an auto-placement OOM.
- A variant with a slow cold start (e.g. modes that initialize a drafter or ngram cache on the first request) could be killed during warm-up for running below 20% of the fastest measured row, before its real throughput was ever measured. The relative spill threshold now applies only to measured runs; the absolute floor still guards warm-ups.
…story winner, exclude errored rows from auto-tune, and skip clamped parallel-slot rows

- The Context length sweep kept the previously selected model's context steps when the target model changed or when the GGUF header resolved after the sweep was picked, so it could benchmark the wrong window. Context rows now rebuild whenever the resolved max context changes.
- History cards reported the fastest non-baseline row as the winner even when the baseline was actually fastest, showing a slower setting with a below-1x ratio. Cards now pick the fastest row overall and compare separately, matching the results panel.
- Auto-tune could pick a candidate that measured one sample and then failed on a later run, and apply that failed setting to Chat. The verdict and the Apply action now only consider rows that ran to completion.
- On llama.cpp builds without --kv-unified, the Parallel slots sweep clamped every row to one slot yet charted 1/2/4 as distinct results. Rows whose requested slot count exceeds what the server actually served are now skipped with the reason instead of being charted.
…model metadata resolves, and persist runs that only produced failure diagnostics

- When the sweep finished but the original chat model failed to reload, the failure was swallowed and the UI implied settings were restored. The runner now reports the restore failure and the Benchmarks page shows it, while still keeping the completed run.
- For context and offload sweeps on a newly picked model, Run was clickable before the model's metadata loaded, so the sweep could start using the resident model's context window or leftover offload rows. Run is now disabled for those sweeps until the picked model's header resolves.
- A benchmark run where every variant failed or was skipped before generating anything was discarded, losing the failure reasons. Such runs are now saved to History; a run cancelled before doing anything is still dropped.
This is a rough first start of the benchmarking feature — it is
riddled with bugs and unfinished in basically every corner. Expect
things to be broken all over the place; this is not in any kind of
working or polished state yet.
Mounts the lm-eval page as a Quality tab beside Benchmark and History instead of
its own /benchmark route and sidebar entry, and fits it to current main:

- Its tables are eval_runs / eval_samples. benchmark_runs is already the speed
  sweeps' table in the same studio.db, and CREATE TABLE IF NOT EXISTS would have
  left whichever feature ran second reading the other's schema.
- The HF token comes from the hub token store (hfToken left the training store).
- scoreColor was used but never defined; added.
- Washes and fixed lengths follow the contrast and UI-size settings, as the
  style tests require.
- Dropped studio/AGENTS.md, the .gitignore lines and the install.ps1 mode change,
  which were local to the fork.
…fails

- On the Benchmarks page, if reading a non-resident GGUF's header failed, the request was swallowed and Run stayed disabled forever for context and offload sweeps with no explanation. The setup now surfaces the error and offers a Try again button that refetches, instead of silently blocking the run.
…g per completion

- Context sweeps could enable Run and build their rows on the resident model's window when the picked GGUF's header resolved without a readable context length (not downloaded, unreadable header, expired lease). Run is now blocked with a retry until the picked model's own context window is known.
- A variant's mean/range/sample count discarded any repetition missing server timings whenever another repetition had them, so the displayed figures could rest on an arbitrary subset of runs. The client-side rate now stands in per completion (both the live aggregation and the stored history means), so every requested run counts.
…ginal chat load before sweep

- The Benchmarks history endpoints (`GET /runs`, `GET /runs/{id}`) returned the stored run verbatim, exposing the loaded GGUF's absolute host path in `model` (and `config.tuneModel`) to any API-key caller, the same filesystem identity the inference status route already redacts. Both endpoints now redact those model paths for API-key callers while leaving browser sessions untouched.
- When a benchmark sweep finished, the code restored Chat's original model by recomputing its load from the live chat store, which Chat's own status polling had meanwhile overwritten with each benchmark variant's KV/context/speculative/offload settings. The original load is now snapshotted before the first model swap and used for restoration, so Chat comes back exactly as it was.
… rows from being treated as OOM

- Benchmark run IDs were timestamp-only, so two runs started in the same millisecond collided and overwrote each other's stored results. Run IDs now carry a random suffix.
- A RAM-offload row that ran slowly by design (experts in system RAM) tripped the 2 tok/s safety floor and was then treated as out-of-memory, skipping all the more GPU-heavy placements after it, including ones that would have fit and run fast. The floor now still stops that row but no longer propagates it as an OOM for offload sweeps.
…ffload rows, and rank only completed rows as history winners

- A benchmark started right after opening the Benchmarks page could snapshot Chat's settings before they finished loading, sweeping (and restoring) with store defaults instead of Chat's real config. runBenchmark now awaits chat-settings hydration before it reads the store.
- RAM-offload rows inherited Chat's -ngl/--n-cpu-moe pass-through args, which the load route promotes over the per-row layer count, so the 25/50/75% and all-on-GPU rows all ran the same inherited placement. Offload rows now drop those inherited offload flags since the sweep owns placement.
- A benchmark row that recorded a measurement and then errored or was cancelled could still be ranked as the run's winner on the history card. Winner and speedup now consider only rows that completed every rep, while partial samples stay in the chart.
…l-row winner selection

- The client-side throughput fallback counted SSE stream chunks instead of tokens, so rows without server timings could report chunk/s as tok/s and mis-rank the winner. It now uses the exact `usage.completion_tokens` from the terminal include_usage chunk, falling back to the chunk counter only if usage is absent.
- The results page could crown a row that errored or was cancelled after one measured rep as the Fastest result, since aggregation keeps partial samples. It now ranks only rows whose outcome is `done` for the Fastest card, speed-up and headline, matching the History and Auto-tune pages, while still charting the partial rows.
- Draft-depth sweeps could chart several rows that all ran at the same depth: if chat's extra llama-server args carried `--draft-max` or `--spec-draft-n-max`, that value was inherited into every benchmark load and overrode each row's requested depth. Rows that own speculative decoding now strip those inherited depth flags from the base args before applying their own, the same way the offload sweep strips inherited placement flags.
# Conflicts:
#	studio/backend/routes/benchmarks.py
# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
#	studio/frontend/src/i18n/locales/ar.ts
#	studio/frontend/src/i18n/locales/de.ts
#	studio/frontend/src/i18n/locales/es.ts
#	studio/frontend/src/i18n/locales/fr.ts
#	studio/frontend/src/i18n/locales/he.ts
#	studio/frontend/src/i18n/locales/hi.ts
#	studio/frontend/src/i18n/locales/it.ts
#	studio/frontend/src/i18n/locales/ja.ts
#	studio/frontend/src/i18n/locales/ko.ts
#	studio/frontend/src/i18n/locales/pt-br.ts
#	studio/frontend/src/i18n/locales/ru.ts
#	studio/frontend/src/i18n/locales/sv.ts
#	studio/frontend/src/i18n/locales/zh-CN.ts
…d KV flags, and tidy

Auto-switch and preview swap the server without a /load call, so a sweep's later rows could run on another model; both now 409 while a sweep holds the lease. KV and draft-cache rows drop chat's inherited -ctk/-ctv/-ctkd/-ctvd, which last-wins over the row. The progress bar counts only a failed row's missing reps, and a second Run click during the lease round trip is ignored. The per-group strip functions become one stripFlags. Adds the nav label to the 11 newer locales so i18n:check:strict passes, and tightens comments.
- Headline metric falls back to the metric name before the filter (MMLU-Pro, MATH, BBH)
  and knows IFEval's prompt_level_strict_acc; samples keep only the headline filter.
- Picker offers GGUFs only and locks during a run; the HF token, model source,
  checkpoint fetch and download branch are gone from the run path.
- Progress events no longer fill the log buffer; ownsRun clears when a run ends;
  deletes bump a runs version the scoreboard refetches on, and failed deletes stay
  listed with their error.
- Run params are validated (422); bbh and mmlu_pro are generation tasks;
  truthfulqa_mc2 is curated; charts name the headline metric; tqdm progress only
  counts the eval worker's bars.
- Dead keys, dialog, barrel and constants removed; benchmark.* translated into all
  locales; hardcoded English moved onto t(); "Run Eval".
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Pushed 9da1ebc529, the head Codex reviewed with no major issues on the fork mirror (LeoBorcherding#136). Since 6e52d7331d:

  • Headline scores for MMLU-Pro, MATH, BBH and IFEval.
  • Per-sample rows follow the headline metric's filter.
  • The Evals picker lists GGUF models only.
  • Bad run parameters get a 422 instead of a 500.
  • BBH and MMLU-Pro are labelled as generation tasks, and truthfulqa_mc2 is added.
  • Every locale passes i18n:check:strict.
  • Dead code removed (compare dialog, unused keys, the stray gguf requirement).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants