Archived
scheduler: --prefill-interleave defaults to auto:1 where nothing pins the schedule
Cause: with --prefill-interleave 0 every step carries a chunk while a prompt prefills, so a sequence already decoding gets one token group per chunk step. On Qwen3.8-Flash-Next fp8 (TP2, MTP 3 drafts) with 8 sessions decoding while 64K-token prompts prefill, that is 12.3 tokens/s a session against ~83 alone; with 4 such prompts at once, 5.4. Change: not given, engine bring-up now serves --prefill-interleave auto:1: after a prefill chunk that ran beside decoding sequences, decode-only steps follow for as long as the chunk step took. --deterministic keeps 0 (a schedule that follows timing is not reproducible), as do KL mode and generators (nothing decodes beside a prefill there); an explicit --prefill-interleave N|auto[:SHARE] wins. Startup names the decision with its reason. The Config default stays 0, so a Scheduler built directly (tests) keeps today's schedule; Config::prefill_interleave_set records the flag. Evidence (decode tokens/s a decoding session / aggregate prefill tokens/s / TTFT), 8 sessions decoding beside 64K prompts: --prefill-interleave 0 12.3 / 3,664 / 17.3 s auto (0.25) 23 / 3,181 / 20 s auto:1 40.9 / 1,823 / 35.5 s auto:2 50 / 1,166 / 56 s with 4 concurrent 64K prefills: 0 5.4 / 2,934 / 64 s; auto 14.8 / 2,545 / 74 s; auto:1 33 / 1,395 / 137 s. auto:1 roughly triples a decoding session's rate for twice the prompt's time to first token. BetterBench quick (short prompts, concurrency 1/2/4/8) shows no reliable difference between 0 and auto: a short prompt is one chunk, after which nothing is held. config_test: the flag records that it was given.
This commit is contained in:
1 parent
6e134fc15f
commit
a58304632a
5 files changed
+42
-8
No files matched your search
+3
-2
@@ -78,8 +78,8 @@ static const Flag g_flags[] = {
|
|||||||
{ "--prefill-interleave", "N", "decode-only steps after each prefill chunk while other\n"
|
{ "--prefill-interleave", "N", "decode-only steps after each prefill chunk while other\n"
|
||||||
"sequences decode, at most 64; auto fits them in a quarter\n"
|
"sequences decode, at most 64; auto fits them in a quarter\n"
|
||||||
"of the chunk step's time, auto:SHARE in SHARE of it (0-4];\n"
|
"of the chunk step's time, auto:SHARE in SHARE of it (0-4];\n"
|
||||||
"0 (default) lets every step\n"
|
"0 lets every step carry a chunk; served default auto:1\n"
|
||||||
"carry a chunk" },
|
"(0 under --deterministic, KL mode, generators)" },
|
||||||
{ "--preempt-wait-ms", "N", "how long a preempted prefill may wait for the whole-\n"
|
{ "--preempt-wait-ms", "N", "how long a preempted prefill may wait for the whole-\n"
|
||||||
"recompute gate before reclaiming cache blocks and\n"
|
"recompute gate before reclaiming cache blocks and\n"
|
||||||
"preempting the lowest-priority running request; 0\n"
|
"preempting the lowest-priority running request; 0\n"
|
||||||
@@ -575,6 +575,7 @@ int config_parse(int argc, char** argv, Config* c) {
|
|||||||
}
|
}
|
||||||
else if (S("--prefill-interleave")) {
|
else if (S("--prefill-interleave")) {
|
||||||
if (!(v = need(i))) return RAD_E_INVAL;
|
if (!(v = need(i))) return RAD_E_INVAL;
|
||||||
|
c->prefill_interleave_set = true;
|
||||||
if (!std::strcmp(v, "auto")) { c->prefill_interleave = -1; c->prefill_interleave_share = 0.25; }
|
if (!std::strcmp(v, "auto")) { c->prefill_interleave = -1; c->prefill_interleave_share = 0.25; }
|
||||||
else if (!std::strncmp(v, "auto:", 5)) {
|
else if (!std::strncmp(v, "auto:", 5)) {
|
||||||
/* auto:SHARE -- decode-only steps for up to SHARE x a chunk step's time, 0 < SHARE <= 4 */
|
/* auto:SHARE -- decode-only steps for up to SHARE x a chunk step's time, 0 < SHARE <= 4 */
|
||||||
|
|||||||
@@ -1350,6 +1350,27 @@ int Engine::declare() {
|
|||||||
: "the model carries no vision tower");
|
: "the model carries no vision tower");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --prefill-interleave not given: auto:1, decode-only steps for as long as a chunk step took,
|
||||||
|
* so decoders keep about half their rate while prompts prefill (measured on Flash-Next: 8
|
||||||
|
* decoders beside a 64K prefill, 12 -> 41 tokens/s each). Not where the schedule must not
|
||||||
|
* follow timing (--deterministic) or nothing decodes beside a prefill (a generator's passes,
|
||||||
|
* KL mode's scoring); an explicit N or auto[:SHARE] is kept as given. */
|
||||||
|
if (!cfg_.prefill_interleave_set) {
|
||||||
|
RadArchProbe pb{};
|
||||||
|
(void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs);
|
||||||
|
const char* none = pb.gen_rows > 0 ? "a generator: its passes carry no decode rows"
|
||||||
|
: cfg_.kld() ? "KL mode scores documents and decodes nothing" : nullptr;
|
||||||
|
if (none || cfg_.deterministic) {
|
||||||
|
decide("--prefill-interleave", "0", none ? none : "--deterministic keeps a "
|
||||||
|
"timing-independent schedule (--prefill-interleave N or auto overrides it)");
|
||||||
|
} else {
|
||||||
|
cfg_.prefill_interleave = -1;
|
||||||
|
cfg_.prefill_interleave_share = 1.0;
|
||||||
|
decide("--prefill-interleave", "auto:1", "decode-only steps for as long as a chunk "
|
||||||
|
"step took while prompts prefill beside decoding sequences");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Control vectors are resolved before any rank declares, because the plugin reads the
|
/* Control vectors are resolved before any rank declares, because the plugin reads the
|
||||||
* direction table from RadBuildCtx. Only `--control-vector off|on` loads one; without it
|
* direction table from RadBuildCtx. Only `--control-vector off|on` loads one; without it
|
||||||
* nothing is looked for and the graph declares no projection op. With it, a plugin that does
|
* nothing is looked for and the graph declares no projection op. With it, a plugin that does
|
||||||
|
|||||||
@@ -840,6 +840,10 @@ struct Config {
|
|||||||
* the chunk at N tokens on such a step. See Scheduler::step, docs/GUIDE.md. */
|
* the chunk at N tokens on such a step. See Scheduler::step, docs/GUIDE.md. */
|
||||||
int64_t busy_prefill_chunk = -1;
|
int64_t busy_prefill_chunk = -1;
|
||||||
double prefill_interleave_share = 0.25; /* --prefill-interleave auto[:SHARE] */
|
double prefill_interleave_share = 0.25; /* --prefill-interleave auto[:SHARE] */
|
||||||
|
/* Whether --prefill-interleave was given. Not given, engine bring-up serves auto:1 (decode-only
|
||||||
|
* steps for as long as a chunk step took) except under --deterministic, in KL mode and for a
|
||||||
|
* generator; the Config default 0 is what a Scheduler built directly (tests) gets. */
|
||||||
|
bool prefill_interleave_set = false;
|
||||||
int64_t prefill_interleave = 0; /* --prefill-interleave: decode-only steps between chunks;
|
int64_t prefill_interleave = 0; /* --prefill-interleave: decode-only steps between chunks;
|
||||||
* -1 auto (Scheduler::interleave_steps) */
|
* -1 auto (Scheduler::interleave_steps) */
|
||||||
/* --preempt-wait-ms: how long a preempted prefill may wait for the whole-recompute gate
|
/* --preempt-wait-ms: how long a preempted prefill may wait for the whole-recompute gate
|
||||||
|
|||||||
+12
-6
@@ -1152,16 +1152,22 @@ chunk's time, and every sequence decoding beside it waits that long for its next
|
|||||||
`--prefill-interleave 2`, after a step that carried a chunk while other sequences were decoding,
|
`--prefill-interleave 2`, after a step that carried a chunk while other sequences were decoding,
|
||||||
the next two steps carry decode rows only and admit nothing, then the next chunk is scheduled. The prompt's time to first token grows by those steps and the
|
the next two steps carry decode rows only and admit nothing, then the next chunk is scheduled. The prompt's time to first token grows by those steps and the
|
||||||
decoders keep their cadence. A lone prefill is not held, nor is the step after a prompt's last
|
decoders keep their cadence. A lone prefill is not held, nor is the step after a prompt's last
|
||||||
chunk. `0` (the default) schedules as before. `/stats` counts the decode-only steps the hold
|
chunk. `0` schedules as before. `/stats` counts the decode-only steps the hold inserted as
|
||||||
inserted as `steps_held`, `/metrics` as `radiance:engine_steps_held_total`.
|
`steps_held`, `/metrics` as `radiance:engine_steps_held_total`.
|
||||||
|
|
||||||
|
Served default: `--prefill-interleave auto:1` (below), so decoding sessions keep about half their
|
||||||
|
rate while prompts prefill; `--deterministic`, KL mode and generators keep 0, and an explicit `N`
|
||||||
|
or `auto[:SHARE]` is kept as given. Measured on Qwen3.8-Flash-Next (fp8, TP2, MTP 3, 8 sessions
|
||||||
|
decoding beside 64K prompts): 12.3 -> 40.9 decode tokens/s a session, aggregate prefill 3.7K ->
|
||||||
|
1.8K tokens/s, time to first token 17 -> 36 s. `--prefill-interleave 0` restores the old schedule.
|
||||||
|
|
||||||
`--prefill-interleave auto` sizes the hold from measured step times instead: after each such chunk,
|
`--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
|
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 64 steps; one until a decode step has been timed). `auto:SHARE` uses SHARE
|
means of both, at most 64 steps; one until a decode step has been timed). `auto:SHARE` uses SHARE
|
||||||
of the chunk step's time instead of a quarter (0 < SHARE <= 4; `auto:1` gives decode as much time
|
of the chunk step's time instead of a quarter (0 < SHARE <= 4; `auto:1` gives decode as much time
|
||||||
as prefill). With the quarter the prefill gives up at most a fifth of its rate however many sequences decode, and the decoders get several steps where a
|
as prefill). With the quarter the prefill gives up at most a fifth of its rate however many
|
||||||
decode step is cheap beside a chunk, none where one costs more than that quarter (they still ride
|
sequences decode, and the decoders get several steps where a decode step is cheap beside a chunk,
|
||||||
every chunk). In the scheduler's host simulation of 32 prompts of 128K tokens sent at once, each
|
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
|
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
|
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
|
from 6.5 to 31 tokens/s each and delayed the last first token by 6 %. Because the hold follows the
|
||||||
@@ -2083,7 +2089,7 @@ by 0.002-0.003 nats.
|
|||||||
| flag | default | |
|
| flag | default | |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `--max-num-batched-tokens N` | 2048 | largest token count one step may carry |
|
| `--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; `auto` fits them in a quarter of the chunk step's measured time |
|
| `--prefill-interleave N` | auto:1 (0 under `--deterministic`, KL mode, generators) | 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, `auto:SHARE` in SHARE of it (0 < SHARE <= 4); `0` lets every step carry a chunk |
|
||||||
| `--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 |
|
| `--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 |
|
| `--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 |
|
| `--max-num-seqs N` | 256 | largest number of sequences one step may carry |
|
||||||
|
|||||||
@@ -455,9 +455,11 @@ TEST(prefill_interleave_takes_a_step_count_up_to_64) {
|
|||||||
Config d;
|
Config d;
|
||||||
REQUIRE_EQ(parse({}, &d), RAD_OK);
|
REQUIRE_EQ(parse({}, &d), RAD_OK);
|
||||||
CHECK_EQ(d.prefill_interleave, 0);
|
CHECK_EQ(d.prefill_interleave, 0);
|
||||||
|
CHECK(!d.prefill_interleave_set); /* not given: bring-up serves auto:1 */
|
||||||
Config c;
|
Config c;
|
||||||
CHECK_EQ(parse({ "--prefill-interleave", "4" }, &c), RAD_OK);
|
CHECK_EQ(parse({ "--prefill-interleave", "4" }, &c), RAD_OK);
|
||||||
CHECK_EQ(c.prefill_interleave, 4);
|
CHECK_EQ(c.prefill_interleave, 4);
|
||||||
|
CHECK(c.prefill_interleave_set);
|
||||||
CHECK_EQ(parse({ "--prefill-interleave", "65" }, &c), RAD_E_INVAL);
|
CHECK_EQ(parse({ "--prefill-interleave", "65" }, &c), RAD_E_INVAL);
|
||||||
CHECK_EQ(parse({ "--prefill-interleave", "-1" }, &c), RAD_E_INVAL);
|
CHECK_EQ(parse({ "--prefill-interleave", "-1" }, &c), RAD_E_INVAL);
|
||||||
/* auto sizes the hold from measured step costs (Scheduler::interleave_steps) */
|
/* auto sizes the hold from measured step costs (Scheduler::interleave_steps) */
|
||||||
|
|||||||
Reference in new issue
Block a user