scheduler: --prefill-interleave auto sizes the decode-only steps from measured step times

Cause: while prompts prefill, a sequence that is already decoding gets one token group per
step that carries a chunk. On Qwen3.8-Flash-Next at TP2 such a step takes a 2048-token
chunk's time (~0.4 s, more on the device under load), so decoders crawl at a few tokens/s
until the queue of prompts drains. --prefill-interleave N inserts N decode-only steps after
each chunk, but a fixed N costs the prefill whatever N decode steps cost, which grows with
the number of decoders, and is too few where decode steps are cheap.

Change: --prefill-interleave auto (default stays 0). After a chunk that ran beside decoding
sequences with its prompt continuing, as many decode-only steps follow as fit in a quarter
of a chunk step's time at a decode step's (running means of both, fed by step_finished from
the step wall times; at most 16; 1 until a decode step has been timed; 0 where a decode step
costs more than that quarter). The prefill gives up at most a fifth of its rate however
many sequences decode. The hold mechanics (no admission while held, steps issued ahead
count, the stager not armed for a held chunk) are --prefill-interleave N's, unchanged.
Under auto which steps carry a chunk follows the device's timing; a number keeps a
reproducible schedule. A chunk's cut and every row's computation are unchanged.

Evidence: sched_test interleave_auto_* (the count from given costs, the step shapes it
produces, nothing held for a lone prefill or when decode steps are too dear); config_test
parses auto. Host simulation of the scheduler (next commit), 32 x 128K prompts sent at
once, 512 tokens each, MTP 3, step costs fitted to a lone 2048-token prefill and to decode
alone: decode of the sequences decoding while prompts wait 6.5 -> 31 tokens/s each, last
first token 826 -> 875 s (+6 %), TTFT p50 453 -> 480 s; fixed N=2 gives 18 tokens/s at
the same cost. Device numbers: the commit that makes auto:1 the served default.
This commit is contained in:
Code000 committed 2026-11-05 20:20:13 +01:00
1 parent f713f449c2
commit f87d03d304
7 files changed
+144 -9

No files matched your search

+13 -1
View File
@@ -1155,6 +1155,18 @@ decoders keep their cadence. A lone prefill is not held, nor is the step after a
chunk. `0` (the default) schedules as before. `/stats` counts the decode-only steps the hold
inserted as `steps_held`, `/metrics` as `radiance:engine_steps_held_total`.
`--prefill-interleave auto` sizes the hold from measured step times instead: after each such chunk,
as many decode-only steps as fit in a quarter of a chunk step's time at a decode step's (running
means of both, at most 16 steps; one until a decode step has been timed). The prefill gives up at
most a fifth of its rate however many sequences decode, and the decoders get several steps where a
decode step is cheap beside a chunk, none where one costs more than that quarter (they still ride
every chunk). In the scheduler's host simulation of 32 prompts of 128K tokens sent at once, each
then decoding 512 tokens (2048-token chunks, MTP 3, step costs fitted to a lone prefill and to
decode alone), auto raised the decode rate of the sequences decoding while prompts still waited
from 6.5 to 31 tokens/s each and delayed the last first token by 6 %. Because the hold follows the
device's timing, which steps carry a chunk differs from run to run; a number schedules the same
steps every time.
**A prefill alone in its step can carry several intervals** (`--prefill-span N`, default 1). A
chunk ends on every checkpoint interval, so a prompt is otherwise prefilled one interval a step.
With
@@ -2070,7 +2082,7 @@ by 0.002-0.003 nats.
| flag | default | |
|---|---|---|
| `--max-num-batched-tokens N` | 2048 | largest token count one step may carry |
| `--prefill-interleave N` | 0 (off) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64 |
| `--prefill-interleave N` | 0 (off) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64; `auto` fits them in a quarter of the chunk step's measured time |
| `--preempt-wait-ms N` | 5000 | how long a preempted prefill may wait for its whole-recompute gate before reclaiming cache blocks and preempting lowest-priority running requests until one overdue request can prefill; `0` falls back on the next step. A preempted request publishes what it computed to the prefix cache, as a finished one does, so its recompute adopts its prompt instead of computing it again; under pressure the cache gives those blocks back, the newest last, before another request is preempted |
| `--busy-prefill-chunk MODE` | auto | a prefill chunk's share of a step that has other work: `auto` leaves decode rows and waiting requests their room (§4.5), `off` takes the whole step, `N` holds it to N tokens |
| `--max-num-seqs N` | 256 | largest number of sequences one step may carry |