Archived
sched: a long prefill leaves the rest of the step its room (--busy-prefill-chunk)
A prefill chunk took every token the step had left (plan_chunk(..., budget)). On a step budget of a few thousand tokens and a prompt of a few hundred thousand, that is every step for a minute or more, and for all of it a decode row behind the prefill in running_ got nothing (`want > budget` -> break) and admission never ran (`while (... budget > 0)`). A mostly-cached turn that needed a few hundred tokens waited for somebody else's whole prompt: on three ranks at --max-num-batched-tokens 2048, a 94,529-token turn with 94,208 cached took 40.6 s to its first token, which landed on the instant a 264,725-token cold prefill ahead of it ended (#61). --busy-prefill-chunk auto (the default) holds a prefill chunk back only when work that would otherwise get nothing is pending in the step: one row plus the draft window for each decode row behind it, a share (an eighth of the budget, at least one quantum) for each prefill behind it and for the next request waiting to start. The chunk never drops under the smallest step the prefill stager overlaps -- under it every routed layer reads its pooled experts synchronously, the -65 % prefill measured at a budget one token under the threshold. Where holding it back for a waiting request or another prefill would leave a remainder under that floor before the checkpoint boundary, the interval is split into two staged halves instead. Decode rows alone only take their few tokens: the chunk ends a quantum short of the boundary and the next step finishes the interval, the same pair of steps a prefill already runs when decode rows are planned ahead of it. (Halving for decode rows too held a long prompt to half-interval chunks for as long as anything decoded behind it, the larger cost.) Whatever the reserve was not used for (a refused admission, a decode row that drafted less than its window) goes back to the chunk before the step is issued. Admission shares the same way, so a cold prompt admitted with others queued behind it does not take the whole step either; an embedding input still runs whole or not at all. A prompt with nothing beside it, and rows already planned ahead of the prefill, are planned exactly as before, so a lone request's steps -- and every greedy output -- are unchanged. `off` restores the old loop including its break. `N` holds a chunk that shares the step to N tokens, rows ahead included (the operator trading prefill speed for every other row's latency); startup warns when N is under the stager's step. The engine hands the scheduler the stager's smallest pass after init (PrefillStager::min_rows, the largest over the ranks). radiance:engine_prefill_chunks_capped_total counts the chunks held back. sched_test covers admission during a long prefill, a decode row behind one, off reproducing the old plan, a lone prefill unchanged, an explicit N with rows ahead and behind, the share handed back when nobody takes it, and the cap's arithmetic at a 2048-token step with the stager at 1025, with and without a share in the reserve.
This commit is contained in:
1 parent
89cee7ce41
commit
04405089cb
14 files changed
+495
-5
No files matched your search
@@ -1748,6 +1748,16 @@ int Engine::serve() {
|
||||
for (auto& rk : ranks_)
|
||||
rio.push_back({ rk->device, rk->ctx.stream(), &rk->program });
|
||||
RAD_TRY(sched_.init(ranks_[0]->program, cfg_, kv_iface_.get(), pc_iface_.get(), rio, &geo_));
|
||||
/* THE SMALLEST STEP THE PREFILL STAGER OVERLAPS. A prefill chunk the scheduler holds back for
|
||||
* other work in the step (--busy-prefill-chunk) is kept at or above it: under it every routed
|
||||
* layer reads its pooled experts synchronously, which costs a long prefill far more than the
|
||||
* step it shares saves. The largest over the ranks, since the step waits for the slowest. */
|
||||
{
|
||||
int64_t stage_rows = 0;
|
||||
for (auto& rk : ranks_)
|
||||
if (rk->stager.enabled()) stage_rows = std::max(stage_rows, rk->stager.min_rows());
|
||||
sched_.set_stage_rows(stage_rows);
|
||||
}
|
||||
|
||||
for (auto& r : ranks_) r->sampler.attach_vocab(vocab_view_.get());
|
||||
|
||||
|
||||
Reference in new issue
Block a user