Repository navigation
Studio: time a continued reply as the whole answer, not just its last pass - #16451
Conversation
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. |
## Summary `Repo tests (CPU, gloo-tp-pp)` failed on #16444 and #16451 in `tests/test_pp_env_gloo.py`, which #16407 added. Neither PR touches pipeline parallel. Both failures are the same case, with an identical value: ``` test_pp_env_gradient_accumulation_and_microbatches[gemma3_ga1_bs4] base_model.model.model.layers.0.mlp.gate_proj.lora_A.weight: Tensor-likes are not close! Mismatched elements: 1 / 64 (1.6%) Greatest absolute difference: 1.5791505575180054e-05 at index (2, 2) (up to 1e-05 allowed) ``` The identical value means the result depends on the runner's CPU, not on chance, so any run that lands on that runner type fails. The adapter comparison runs after several optimizer steps, so it carries the fp32 reduction-order noise of a 2-stage split against the single-process reference. The file already records that noise for the grad norms ("3e-5 absolute ... between two identical reference runs"). On this host, the largest adapter difference across all five cases of the test is 3.7e-6, which is why 1e-5 looked safe. ## Change `tests/test_pp_env_gloo.py`: in `test_pp_env_gradient_accumulation_and_microbatches` only, the trained-adapter comparison takes `atol = 5e-5`, about 3x the CI value. `rtol` is unchanged, and so is every other `_same_tensors` call: save_pretrained, Trainer.save_model and export. The `_close` call just before it is also unchanged. It pins the step count and every loss at rel 1e-5. It pins the first grad norm at rel 1e-5 and the rest at 1e-4. ## Testing - `tests/test_pp_env_gloo.py`: 14 passed, 1 skipped. - Sabotage: I temporarily scaled every `lora_A` by `1 + 1e-4` in the pipeline-parallel ranks only. `[ga1_bs4]` and `[gemma3_ga1_bs4]` both still fail, as they do at `1 + 1e-3`. So a real divergence much smaller than any pipeline bug would be still fails the test.
[skip ci]
|
Review record for #16451, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#685. 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
|
A review of #14909 reported that when a reply reaches Max Tokens and automatically continues, the timing tooltip describes only the continuation. Their reply had 128 tokens in the first part and 11 in the continuation, and the tooltip showed "11 tokens / 348 ms" for the 139-token answer. This predates #14909.
Problem
A continued reply (Max Tokens auto-continue, or Continue / Resume) shows one merged answer. Its badge, timing tooltip and response details still describe only the last request, under labels like "Tokens" and "Total" that read as totals for the whole answer.
Cause
Each continuation is a new request with its own
streamStartTime. The adapter builds the reply'stiming,serverTimingsandresponseDetailsfrom that request alone, while the text starts from the resumed partial. The continuation request already carries the resumed reply's reasoning time (reasoningDuration), which is why "Worked for" covers the whole answer; nothing carried its timing.Fix
utils/continued-timing.ts: reads a reply's own figures from its metadata and adds them to a pass's figures. Counts and times add up, the first token is the answer's first, and a rate is the time-weighted mean of the passes' rates, which keeps llama.cpp's definition (decode steps over decode time).thread.tsx: Continue carries the resumed reply's figures asContinuationRequest.priorTiming.chat-adapter.ts: a pass counts its own output (itsusage, or an estimate of only the text it appended) and adds the earlier passes. The response details start at the first pass, and their duration is the passes' own time, not the wait before a manual Continue.resumeTiming, the passes so far, for Resume to read.Behavior boundaries
Verification
Live A/B with Playwright on fresh Studio homes, gemma-3-270m-it UD-Q4_K_XL on the CPU, the first request capped at 64 tokens so it stops on
lengthand auto-continues, as in the report; main wasd8efd157abfor the first table and6401ceda29for the second and the screenshot.Stop pressed during the continuation, then Resume:
Tests:
continued-reply-timing.test.ts: two and three passes adding up, the report's 128 + 11 merging to 139, a stopped and a broken-off reply's carried figures read by Resume, a never-continued reply left unchanged, and the adapter's wiring (checked in the source, since the adapter only runs against a live stream; the Stop path is exercised end to end above).Not exercised live: three continuations by Max Tokens alone, and a pass that fails with an error rather than a Stop.
Screenshots
The legend's first-pass figures come from the stored messages:
Additional verification
A regression in the submitted aggregation moved a failed continuation's reply timestamp into the future. Fixed in 1e381c3 by preserving the finish time when combining active durations. The regression test failed with 13,548 instead of 9,348 before the fix and passes afterward. Both comment-reduction passes are complete and passed the comment-only checks.
At head a38b0d4, fresh isolated Studio builds at merge base 6401ced and the PR head received the same scripted 128-token first pass and 11-token continuation. Both sent two requests and rendered identical answer text and byte-identical system prompts. Request bodies matched after removing the isolated homes' provider and thread IDs. The tooltip changed from 11 to 139 tokens, and from 300ms to 4.10s generation. These supplied timing values verify aggregation; they are not a model speed benchmark.
The same two-pass differential also passes in Chromium, Firefox, Microsoft Edge and WebKit, with unchanged request content.
The affected continuation, timing and reply-time tests pass (149 tests); TypeScript checking passes. The broader frontend suite passed 14,618 tests with zero failures and one Windows-only test skipped on Linux. Linux, macOS and Windows scoped staging tests passed for the functional fix.
Studio UI regression check
Base
6401ceda2vs heada38b0d4dd. Functional: NO_REGRESSION, 1 visual change(s), 0 text-only change(s). Only steps whose screenshots differ are shown.continued_reply_timing: Same scripted response in fresh base and head installs. These supplied server timings prove aggregation, not model speed. Chromium, Firefox, Edge and WebKit pass; requests and answer text are unchanged.

Facts:
tokens: {'before': 11, 'after': 139};generation_ms: {'before': 300, 'after': 4100}