Repository navigation
Studio: estimate the prompt's time left from how the cost per token grows, not the rate so far - #16450
Conversation
…rows, not the rate so far
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Review record for #16450, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#686. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
…ip and the weight placement row (unslothai#16452) A review of unslothai#14909 reported that in another language its new strings stay English, while the Generation details setting itself is translated. ## Problem With the UI in German, a GGUF chat shows "Processing prompt 15% · 4s left · 2.049 / 13.626 tokens · 2.710 tok/s": German digits, English words. The same goes for "Working...", the live line under a streaming reply, every row of the reply's timing tooltip including the new "Stop reason" values, and the "Weight placement" row in Run settings. ## Cause unslothai#14909 kept these strings in the code, as its description says ("The live strings are English, like the 'Working...' they replace"). `generation-progress.ts` and `partial-offload.ts` build the sentences around numbers already passed through `toLocaleString`. `message-timing.tsx` had no translation at all before unslothai#14909, which added "Stop reason" and "Draft accepted" to it. ## Fix - A `generationStats` namespace in `en.ts` holds whole templates with placeholders ("{count} tokens", "{eta} left", "{gpu} of {total} layers on the GPU, {cpu} on the CPU"), so each language can order the words around the numbers. - `formatPrefillDetails`, `formatPrefillTimeLeft`, `formatLiveDecode` and `describePlacement` take the `t` function from `useT()`, as `scheduled-tasks/results.ts` does, so they stay plain functions for the tests. The Run settings panel passes the memory pool as `"unified"` / `"shared"` instead of English words. - The prompt line ("Working..." included, since the two alternate in one span), the live line, the whole timing tooltip with its button label, and the Weight placement row read from the catalog. - All 24 overlays carry the new keys, in a separate commit as the i18n README asks, reusing each overlay's existing words for token, prompt, cache, layers, experts, draft and unified memory. - The catalog has only a one/other pair, which cannot give Russian "2 токена" and "21 токен" next to "5 токенов". So Russian, Ukrainian, Polish, Czech and Arabic put the count after a label ("токены: 21") wherever it stands before a noun. ## Behavior boundaries - English output is unchanged; the existing English assertions in `generation-details.test.ts` pass as they were. - "tok/s", GPU, CPU, RAM, VRAM, GiB, MiB and the compact durations ("12s", "2m 10s") stay as they are, as elsewhere in the app. - Only these four pieces are moved. The rest of the Run settings panel, the reply's action bar and "Cancelled." were English before unslothai#14909 and still are. ## Verification Live A/B with Playwright on fresh Studio homes, gemma-3-270m-it UD-Q4_K_XL on the CPU, a 13.6K-token prompt, Generation details on, UI in German; main was `d8efd157ab` for the run below and `6401ceda29` for the screenshot. With this PR the prompt line reads "Prompt-Verarbeitung 15% · noch 4s · 2.049 / 13.645 Tokens · 2.520 tok/s", the live line "130 Tokens · 115,1 tok/s · Draft 107/128 akzeptiert (84%)", and the placement row "Platzierung der Gewichte · Alle 19 Schichten auf der CPU". The same four places render in Japanese, and the tooltip keeps its layout with the longer German labels. Tests: - New: the formatters and the placement description render the German overlay's templates with German number formatting; the prompt line, tooltip, placement row and `generation-progress.ts` no longer hold the English sentences; in Russian, Ukrainian, Polish, Czech and Arabic no count stands before a noun. - `i18n:check:strict` passes with no missing keys. The 830 tests in files touching these formatters, components or the locale files pass. Typecheck passes; ESLint has no new findings. - The startup bundle stays within budget; the i18n chunk grows by 1.6 KB raw (0.6 KB transfer). Not checked by a native speaker: the 24 overlays. ## Screenshots UI in German on both sides:  <!-- generation-evidence:start --> ## Verified before and after Separate Studio installs at base `ac7229860e` and integrated head `7cdeff4ae7`, with German selected and identical recorded progress frames. The fitted estimate from unslothai#16450 stays at 20s on both sides; the prompt-progress and draft-acceptance labels become German while all numbers remain identical. These pictures verify presentation, not model throughput.   Validation at this head: 26 focused generation-details tests pass, full frontend suite 14,644 passed and zero failed, production build passes, and strict parity passes for all 25 catalogs. The merge resolution explicitly checks the fitted estimate renders as "noch 20s". <!-- generation-evidence:end --> --------- Co-authored-by: Daniel Han <[email protected]>
A review of #14909 reported that the "time left" while a GGUF reads a long prompt is too optimistic: it showed 26 s when about 42 s remained.
Problem
"Processing prompt N% · Xs left" runs short for the whole prompt, and by more the longer the prompt is. On a 30K-token prompt it read 38% to 49% short at every point.
Cause
prefillSecondsLeftdivides the remaining tokens by llama-server'sprompt_per_second, the average rate since the pass started. That assumes every remaining token costs what the earlier ones did. Each prompt token attends to every token before it, so the cost per token grows with its position: the time per 2,048-token batch rose about linearly in every run below (0.60 to 1.55 ms per token on one prompt). A rate over a recent window still lags the growth; on the same samples it stayed 15% to 49% short.Fix
routes/inference.py: the prefill frame also carries llama-server'stime_ms, its own clock since the pass started. The client cannot time the frames itself, because they reach it through the 0.25 s stall poll, which sends only the newest sample.generation-progress.tsand the runtime store: each timed sample of a pass adds to eight running least-squares sums, and the time left comes from the fitc + a*x + b*x^2of elapsed time over tokens (a straight line if the curve bends the wrong way).Behavior boundaries
time_mskeeps main's estimate throughout.Verification
Unless noted, runs on the CPU, gemma-3-270m-it UD-Q4_K_XL, fresh Studio homes, main at
6401ceda29.Live A/B through the page, alternating, the same 27K-token prompts, the label read every 100 ms. Error of the shown time left against the time that actually remained, from 30% to 82%:
Below 30% this branch read -43% to -10%, never over. A replay of llama-server's own samples from 10 prompts (two models, Studio's llama-server flags, three runs recorded by Studio) gives the same picture: main -34%, this branch -9% (mean absolute 11%).
One slow batch, through the same functions (2,048 tokens per 500 ms, batch 4 taking 250 ms longer):
On an RTX 6000 Ada, with Studio's llama-server flags: each prompt's progress samples, replayed through both versions the way the page receives them (the newest sample every 0.25 s). The cost per prompt token grows on the GPU too, 2.5x across 58K tokens on gemma-4-E2B and about 4x across 107K on Qwen3.6-35B-A3B. Error from 30% to 83%:
Tests:
save-temporary-chat.test.tsfails the same way on main (the bundled Node 22.12 lacksstripTypeScriptTypes). Backend live-progress, frame-spoofing and chat-run supervisor suites: 110 passed. Typecheck passes; ESLint has no new findings.Not tested: Metal, and prompts with images.
Screenshots
The same 27K-token prompt on both sides; the legend gives the time that actually remained:
Verified before and after
Separate Studio installs at base
6401ceda29and head71aedfe885, using identical recorded progress frames. At 53%, the estimate changes from 12s to 20s left; the recorded completion leaves 20.57s at this sample. Counts and prompt rate are unchanged. This is a replay through the real UI, not a model-throughput measurement.