Repository navigation
Studio: keep a still-advancing llama.cpp prefill from timing out - #10172
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. |
|
Confirmed main only sets return_progress when a perf callback is attached, so prompt_progress events never renew the first-token deadline in _iter_text_cancellable, and an advancing prefill past 1200s still gets cancelled. Will get this reviewed. |
|
A prompt that takes more than 20 minutes to prefill is no longer cancelled while the server is still working on it. The deadline now resets each time llama.cpp reports more prompt tokens processed, so 1200 seconds means 20 minutes without progress rather than 20 minutes total, and it still fires on a server that has gone silent or is replaying the same progress value. I checked both against a real llama-server: with the previous payload the request times out at the deadline, with this one the prefill completes. Nothing else about the reply changes. Output is identical with and without Two limits to be aware of. The passthrough path in |
Addresses the 20-minute cancellation reported on Reddit, in #9037, and again here. Related reports: #5756 and bug 3 of #5130.
Problem
_DEFAULT_FIRST_TOKEN_TIMEOUT_Scounts 1200 seconds from when the request starts._iter_text_cancellablestops that clock only when an SSE event carries generated output. llama-server's prefill progress events do not count, so prompt processing never resets the deadline.A prompt that takes longer than 20 minutes to prefill is therefore cancelled even though the server is healthy and still advancing. From the reporter's log, at 93% and climbing:
The user loses the whole prefill and gets a message advising them to shrink the model. No UI setting affects the module constant. #5841 already raised it from 120 seconds, but long active prefills can still hit the new ceiling.
Fix
Studio now requests
return_progresson all three chat streams instead of only when a perf callback is attached.timings_per_tokenstays opt-in, and older servers ignore the progress field._iter_text_cancellablerenewsfirst_token_deadlinewheneverprompt_progress.processedincreases. The constant is unchanged: 1200 seconds now means 20 minutes without progress instead of 20 minutes total. Silence and repeated progress values still time out.The JSON decode shared by both readers moved into
_sse_event_payload, so each event is parsed once.Verification
tools/server/server-context.cppemits an initial event and one progress event per prompt batch. llama.cpp'stest_return_progressasserts thatprocessedstrictly increases per batch, so the watchdog relies on an upstream contract.With the bundled
llama-server, a 351-token prompt at-b 32produced 12 events from 0 through 351. All parsed as increasing prefill progress without being misclassified as generated output. A warm-cache repeat correctly produced two events,processed == cache == 341then 342.At the default 2048 batch, prefill has to fall under roughly 2 tok/s before the window can still trip. The reported case was running at about 130 tok/s, an event roughly every 16 seconds.
Tests:
test_llama_cpp_stall_timeout.py: advancing progress survives 4000 seconds of fake time, a repeatedprocessedvalue still times out, and content-free events with no progress field still time out. The first fails on the parent commit with the sameReadTimeoutthis PR removes.structlogstub shares their process; running those files separately gives 151 passed.Scope
This stops the cancellation. It does not make the prefill faster, and it does not touch the cache invalidation in #9037 that forces the full re-prefill in the first place, so that issue should stay open. Users will still wait, but Studio now lets the wait finish.
A server that advances indefinitely is now held open instead of cancelled. That is the deliberate trade in treating progress as liveness, and Stop still works.
Builds without
prompt_progresskeep the fixed cutoff. The passthrough path inroutes/inference.pyalready disarms its deadline on any received item, so unifying the two paths is separate work. The timeout also remains non-configurable, as originally requested in #5756.