Skip to content

fix(inference): a stalled stream on a lane working for others waits on, bounded; only a lane that did nothing fails it (card 115f9a14) - #4506

Merged
joelteply merged 1 commit into
canaryfrom
fix/a-starved-stream-keeps-waiting
Sep 28, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/a-starved-stream-keeps-waiting

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What broke: on the IntelMac at 05:07Z on 2026-09-28 (Cormac's read), a turn at 96% prefill failed at the 90 s idle bound (inference.decode.failed kind=keepalive_masked_no_progress). Meanwhile the server was prefilling slot 4's next 2,048-token chunk, about one every ~176 s at 11.6 tok/s, so our stream's own counters stood still. #4480 already stopped counting that as wedge evidence, but the turn still failed (sse_stream: "the turn still fails either way"). It is the busy-is-not-dead class behind the node's 41% dropped generations.

Fix:

Test: a_stalled_stream_waits_on_a_working_lane_and_only_there. It covers a working lane (waits on), a lane with no work (ends), a lane never observed (ends), and past the ceiling (ends).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES REQUESTED at fcee991. The waiting rule is right, and so is the bounded ceiling (the act's own 3x). One defect in how it's wired: the decision is read twice.

In both the no-bytes path (~line 454) and the progress-stall path (~line 522), the existing #4480 block still runs first:

  • classify_never_started_timeout(ms_since_real_work(), idle): on WedgeEvidence it logs decode.failed and calls note_real_decode_failure(); on Starved it logs inference.queue_starved, whose text says "the turn still fails either way".
  • Then starved_on_a_working_lane() re-reads ms_since_real_work() and decides again whether to wait or fail.

Consequences:

  1. Contradictory rows every checkpoint. On a working lane, each 90 s wait logs queue_starved ("the turn still fails") and then busy_not_dead ("waiting on"). A reader of the IntelMac log gets both, forever, for one healthy wait.
  2. The two reads can disagree. ms_since_real_work() is a live clock, so between the reads a neighbour's prefill can land. If the first read is WedgeEvidence, note_real_decode_failure() stamps a relaunch strike, and the second read is Starved and waits on: a strike against a lane that kept serving, the exact false relaunch fix(inference): a stream whose own progress stalls on a lane that is delivering to others is starvation, not wedge evidence (card 2caa0de5) #4480 exists to prevent. The opposite order fails the stream with no strike and no row naming the ending.

Fix: classify once per checkpoint, one match with three arms:

  • Starved and open < STARVED_WAIT_CEILING → busy_not_dead, reset last_progress, wait on (no queue_starved, no stamp);
  • Starved past the ceiling → queue_starved (the text is now true: the turn fails, no strike) → Err;
  • WedgeEvidence → decode.failed plus note_real_decode_failure() → Err.

waits_on stays the pure decision, taking the one ms_since_real_work read, and the test extends to the three arms. That's also where #4505's fields (persona, purpose, phase, prefill processed/total, ms_since_lane_work) belong, on each arm's row. If this lands after #4505, I'm happy for you to fold them in, as you offered.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply added a commit that referenced this pull request Sep 28, 2026
joelteply added a commit that referenced this pull request Sep 28, 2026
…asured prefill rate, so a slow lane between counter moves reads as working (Codex on #4506); UBATCH_TOKENS set once in lane_args

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 28, 2026
…rate, covering the IntelMac's measured chunk-gap jitter (214 s at 11.6 tok/s) (Cormac on #4506)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 28, 2026
joelteply added a commit that referenced this pull request Sep 28, 2026
…asured prefill rate, so a slow lane between counter moves reads as working (Codex on #4506); UBATCH_TOKENS set once in lane_args

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 28, 2026
…rate, covering the IntelMac's measured chunk-gap jitter (214 s at 11.6 tok/s) (Cormac on #4506)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 28, 2026
…irst (serving_rates), the per-request rate only as fallback; test comment says two ubatches (Cormac on #4506)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fix/a-starved-stream-keeps-waiting branch from 39ae393 to c26145c Compare September 28, 2026 05:37
…n, bounded; only a lane that did nothing fails it (card 115f9a14)

IntelMac 2026-09-28 05:07Z (Cormac's read): a turn at 96% prefill failed at the 90 s idle bound
while the server prefilled slot 4's 2,048-token chunk every ~176 s. Both the no-bytes timeout and
the progress stall now take ONE classification of the lane per checkpoint (lane_class): a lane
that did real work for anyone within the work window (the idle bound or two ubatches at the
server-total prefill rate, whichever is longer) is busy, so the bound becomes a checkpoint
(inference.stream.busy_not_dead) and the stream waits on, up to the act's own 3x ceiling. Only a
lane that did nothing fails the stream and counts toward relaunch. UBATCH_TOKENS is set once in
lane_args.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fix/a-starved-stream-keeps-waiting branch from fa1ae75 to 7fd2124 Compare September 28, 2026 05:56
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVED #4506 at 7fd2124: 8/8 concluded success. At both checkpoints (no bytes, progress stall) the lane class is read ONCE, and waits_on plus the fail match both use it, so Starved within the ceiling waits with no strike, and only WedgeEvidence strikes. The work window is max(idle, 2 ubatches at the server-total prefill rate), covering the IntelMac's measured 214 s chunk gap. UBATCH_TOKENS carries its derived-or-floor and context-budget exemption. The busy_not_dead and fail rows carry #4505's persona, purpose, phase, prefill progress and ms_since_lane_work.

@joelteply
joelteply merged commit a024301 into canary Sep 28, 2026
8 checks passed
@joelteply
joelteply deleted the fix/a-starved-stream-keeps-waiting branch September 28, 2026 06:19
joelteply added a commit that referenced this pull request Oct 26, 2026
…e no-movement window for every engine wait (card 0b52b957) (#5462)

* A page save behind another slot's prefill is not a stopped engine: one no-movement window for every engine wait (card 0b52b957)

enrico, 2026-10-26 07:59-08:59Z: 3 of 3 page-save quotes were refused 15-17 s after the other
slot began a 2,048-token batch at 10.4-15.4 tok/s (~130-200 s per batch), each mind cold on
her next turn (page_on_disk_unconfirmed at 08:14, 08:34, 08:54). The engine's /slots counters
advance a whole batch at a time, and wait_while_engine_progresses ended any wait at its first
checkpoint when a slot was processing and nothing had moved. The page switch checkpoints at
3x its measured p90 (16.8 s there), far shorter than one batch.

sse_stream already owned the right answer, "two batches at the measured prefill rate, never
less than the floor, capped at the act ceiling" (work_window, #4506). It moves into
llama_server::progress as unmoved_window, the one authority for how long a processing engine
may stay unmoved, and every wait that reads /slots uses it:
- WaitBounds { checkpoint, unmoved }: a plain Duration converts to both (the old strict
  reading), so callers that pass a bound are unchanged;
- page switches (quote, save, restore receipt) pass WaitBounds::for_model(bound, the
  endpoint's launched model), read from the launch contract so a relaunch drain's saves
  are covered too;
- the header wait passes WaitBounds::for_model(header_bound, its model);
- the stream's starvation check calls unmoved_window directly.
The refusal and busy probes now carry unmoved_ms.

Tests (IntelMac, metal + test-fixtures, 33 passed):
- a save behind a 190 s batch is served;
- a receipt landing mid-window wins;
- a never-moving engine ends within one checkpoint of the window;
- a plain Duration is still stuck at once;
- the moved window test covers no rate (floor) and a vanishing rate (capped).
Mutation: restoring "processing and unmoved is stuck at once" fails the enrico fixture
("a switch behind a 190 s batch is served, not refused"). source-hygiene 60/60.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* unmoved window: the ceiling caps the rate's part, never the caller's floor (documented, pinned; Codex on #5462)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Oct 26, 2026
…mes it (card e1a5a21a) (#5468)

* The no-movement window takes the SLOWER measured prefill rate, and names it (card e1a5a21a)

#5462 follow-up, measured on enrico 2026-10-26 13:15-14:15Z (0eeceda): 3 page-save quotes
were still refused as "stopped progressing", with unmoved_ms 23,571 / 59,427 / 64,419. The
per-request prefill rate read 9.7-16.2 tok/s (serving.prefill_rate.moved at 13:17, 13:28 and
14:13), so two 2,048-token batches take 250-420 s; the windows used imply 64-174 tok/s, the
server-total rate unmoved_window preferred. Each refusal cost a mind her page.

The errors are not symmetric: a window too long only delays calling a stuck engine (capped by
UNMOVED_CEILING); a window too short refuses a working engine. window_rate (pure) takes the
slower usable measurement and says which. WaitBounds carries the rate and its source, and the
kv_page admission_refused and busy_not_dead probes report them. This reverses #4506's
server-total preference, which assumed a long window was the costly error.

Test: the_window_is_sized_from_the_slower_measured_rate (enrico's numbers: 9.7 vs 68 tok/s gives
a >400 s window; the old choice gave ~60 s). Not built locally: no cargo on enrico while
residents serve; CI compiles and tests it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* window docs: 250-420 s is TWO batches; one batch is 125-210 s at 9.7-16.2 tok/s (Codex on #5468)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant