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
+18
-1
@@ -465,6 +465,17 @@ public:
|
||||
int64_t plan_chunk(int64_t n_computed, int64_t n_target, int64_t budget,
|
||||
int64_t* checkpoint_pos) const;
|
||||
|
||||
/* THE SMALLEST STEP THE PREFILL STAGER OVERLAPS, in tokens (0 = no stager), set once by the
|
||||
* engine after init. --busy-prefill-chunk keeps a held-back chunk at or above it; see
|
||||
* busy_cap. Also where the resolved policy is stated at startup. */
|
||||
void set_stage_rows(int64_t rows);
|
||||
/* Visible for tests: the most a prefill chunk at `n_computed` of a `n_target`-token sequence
|
||||
* may take of `budget` when `reserve` tokens of other work are still to be planned in the step
|
||||
* and `shared` says rows are already planned ahead of it. Returns `budget` when
|
||||
* --busy-prefill-chunk is off, or when auto has nothing to reserve. */
|
||||
int64_t busy_cap(int64_t n_computed, int64_t n_target, int64_t budget, int64_t reserve,
|
||||
bool shared = false, bool rows_only = false) const;
|
||||
|
||||
private:
|
||||
Program* prog_ = nullptr;
|
||||
Config cfg_{};
|
||||
@@ -472,6 +483,10 @@ private:
|
||||
KVGeom kvgeom_{};
|
||||
/* Does this model carry recurrent state a prefix hit would have to restore? See admit_one. */
|
||||
bool has_linear_state_ = false;
|
||||
/* set_stage_rows: the prefill stager's smallest pass, 0 when it is not armed. */
|
||||
int64_t stage_rows_ = 0;
|
||||
/* Set by admit_one when it held the admitted chunk back: what it would have taken. */
|
||||
int64_t admit_full_ = 0;
|
||||
IKVManager* kv_ = nullptr;
|
||||
IPrefixCache* pc_ = nullptr;
|
||||
|
||||
@@ -719,7 +734,9 @@ private:
|
||||
/* RAD_OK, a negative status when the request cannot be admitted now -- nothing behind it is
|
||||
* either -- or kAdmitWait when its context is still being read off disk and the next request
|
||||
* may go ahead of it. */
|
||||
int admit_one(SchedReq& s, int64_t budget);
|
||||
/* `reserve`: tokens of the step to leave for the requests queued behind this one
|
||||
* (--busy-prefill-chunk; busy_cap). 0 plans the chunk on the whole budget, as before. */
|
||||
int admit_one(SchedReq& s, int64_t budget, int64_t reserve = 0);
|
||||
static constexpr int kAdmitWait = 1;
|
||||
/* The queue positions one step's admission took, kept to reuse the allocation. */
|
||||
std::vector<size_t> took_;
|
||||
|
||||
Reference in new issue
Block a user