Archived
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:
1 parent
f713f449c2
commit
f87d03d304
7 files changed
+144
-9
No files matched your search
@@ -504,6 +504,12 @@ public:
|
||||
* multi-token chunk past the floor would overwrite keys its own earlier rows still read, while
|
||||
* one token a step attends as its decode step did. Otherwise `n_target`. */
|
||||
int64_t chunk_end(const Request& r, int64_t n_target) const;
|
||||
/* --prefill-interleave: the decode-only steps that follow a chunk run beside decoding
|
||||
* sequences. N as configured; under auto, from the measured step costs (see the definition).
|
||||
* Visible for tests, as is note_step_cost, which feeds auto a step's wall time as
|
||||
* step_finished does: `chunk` for a step that carried a prefill chunk, else a decode step. */
|
||||
int64_t interleave_steps() const;
|
||||
void note_step_cost(bool chunk, double seconds);
|
||||
|
||||
private:
|
||||
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
|
||||
@@ -774,6 +780,14 @@ private:
|
||||
* the hold is spent, or the chunk would wait as long as the decoders keep stepping ahead. */
|
||||
int64_t interleave_left_ = 0;
|
||||
int64_t held_prefill_ = 0;
|
||||
/* --prefill-interleave auto: the decode-only steps after a chunk (interleave_steps), sized by
|
||||
* the running means of a step that carried a chunk and of a decode step, in seconds, fed by
|
||||
* step_finished. */
|
||||
static constexpr double kInterleaveShare = 0.25;
|
||||
static constexpr double kInterleaveEma = 0.25;
|
||||
static constexpr int64_t kInterleaveAutoMax = 16;
|
||||
double ema_chunk_s_ = 0.0, ema_decode_s_ = 0.0;
|
||||
void step_cost_locked(bool chunk, double seconds);
|
||||
/* The throughput window (step_finished): each kind's tokens and the wall time the steps
|
||||
* covered, both decayed with the same time constant, so their ratio is tokens over time. */
|
||||
double tps_win_prefill_ = 0.0, tps_win_decode_ = 0.0, tps_win_time_ = 0.0;
|
||||
|
||||
Reference in new issue
Block a user