Repository navigation
Unsloth Studio / Desktop: add a llama-bench tab to Benchmarks and keep llama-bench in the llama.cpp install - #12522
Open
LeoBorcherding wants to merge 136 commits into
Open
LeoBorcherding wants to merge 136 commits into
LeoBorcherding wants to merge 136 commits into
Conversation
…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.
… at the menu's available height
…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 the chart fits the window
…sloth into studio-benchmarks-page
…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.
…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.
…p draft-cache variants from depth lines - The speculative sweep was dropping the Auto (Studio default) row whenever the server fell back (MTP didn't fit, partial offload, etc.), so the sweep omitted the baseline it promised to compare against. Auto now keeps its resolved fallback; only forced modes are marked skipped on a fallback. - The DSpark "By draft depth" chart plotted the q8_0/q4_0 draft-cache rows as extra points at draft depth 3, stacking three measurements at one x and connecting cache-type differences as if they were depth changes. Draft-cache variants are now excluded from the depth line, like tuned ngram rows already are.
…overrides - The History endpoint aggregated throughput across every measurement ever stored on each load, even though only the newest ~200 runs are returned. The aggregation now scopes to the listed run ids, so the scan no longer grows with total history. - Inherited ngram tuning written in equals form (e.g. --spec-ngram-mod-n-match=12) leaked into a speculative sweep's plain Ngram/Auto rows because the stripper only matched the space-separated spelling. It now normalizes the flag name before comparing, matching the offload and spec-depth strippers.
- Parallel-slot benchmark rows could inherit a `-np`/`--parallel` override from Chat's Extra Arguments, which llama.cpp applies last-wins, so the 1/2/4-slot rows all ran the same slot count and produced a mislabeled comparison the served-status check couldn't catch. The sweep now strips inherited parallel flags before loading each row, the same way it already strips offload and draft-depth flags.
# Conflicts: # studio/backend/routes/benchmarks.py
# Conflicts: # studio/backend/routes/benchmarks.py
# Conflicts: # studio/frontend/scripts/check-bundle-budget.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.
…iew fixes - A persisted restore carries its job id and only resumes for that run; the put-back skips when another model is already loaded - llama-bench spawns through the process-lifetime helpers and is killed when Stop's terminate doesn't end it within 10 s - The job turns terminal only after the run is saved; saved runs keep their status and show "Stopped/Failed at n of m" - Copy as markdown matches -o md (MiB, M params, fa only when not auto) - Lease take/extend/drop are public helpers in routes/benchmarks.py; a load refused under a llama-bench lease gets a GPU-busy message - Past runs shows with one run; GiB and t/s labels; persist key renamed
Collaborator
Author
|
Pushed
|
…ld, drop Studio branding from a desktop surface comment
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a llama-bench tab to the Benchmarks page. It runs llama.cpp's own benchmark on the loaded or picked GGUF and shows prompt-processing and generation throughput per test.
Config sweeps answer "what's fastest for my chat" through the real server. This tab answers the other question: the standard pp512 / tg128 number people quote in llama.cpp perf threads, measured without our server or settings in the way, so a slow card and a slow config can be told apart.
Stacked on #11808. Until that lands, this diff includes its commits. Phase 2 of #11646. The installer half (keeping
llama-benchin the llama.cpp install) landed separately as #14881, so this PR is the tab only.What it does
-d, to see speed fall off as a chat gets long), repetitions, and flash attention auto/on/off.-o mdtable shape, a past-runs list with delete, live progress ("x of y tests"), Stop and the llama-bench log.How it looks
Unsloth Studio (web) on a Colab T4, Qwen3-4B Q4_K_M.
Picking another model (Llama 1B) while Qwen is loaded: load, run, Qwen back:
The tab against llama-bench run by hand with the same flags:
Backend
routes/llama_bench.py, mounted at/api/benchmarks/llama-bench:status,POST/GET/DELETE /run.gguf_pathof the model Chat has loaded._unload_model_impl, the same path as/unload, so a chat still generating gets a 409 instead of being cut off.-o jsonl --progressand parses rows as they land. Finished (or stopped, with at least one row) runs are saved tobenchmark_runsas kindllama-bench;GET /runstakes?kind=(defaultsweep), so the sweeps' History doesn't pick them up.Known gaps
-nglis supported by the API (-ngl 0checked) but has no UI control yet.facolumn of-1that llama-bench's own table leaves out.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.
4c14f37, lockout rows at7bcd9183c1-ngl 0; API key and managed account; sweep lockout; light and dark at 1024 / 1440 / 1920Numbers, Qwen3-4B Q4_K_M,
-p 512 -n 128 -r 5:Not run: AMD, Windows, macOS, Unsloth Desktop, a source build of llama.cpp.
Tests
Measured at
ff9a85d26f(up to date with main), macOS, Apple M5: frontend typecheck,npm test0 fail, build,bundle:check,i18n:check:strict; backendtest_llama_bench.py(9, includingtest_a_run_and_a_config_sweep_lock_each_other_out),test_benchmark_runs.py,test_llama_server_args.pypass.Full results with logs: LeoBorcherding#311 (comment 6457224317).