Archived
sched: no step issued ahead behind a step that ends every request it carries
A pipelined engine issues each step's successor before the step is read back: block drafters (DFlash, DFlash2) since 1.11.0, serial MTP and decoding without a drafter since 1.0.0. The step that emits a request's last token therefore had one more step queued behind it, for a request its commit then finishes. That step verifies nothing, yet the card runs its whole forward pass and the drafter's context pass behind it, and a request that arrives once the last token is out -- a single-stream client's next turn, sent as the reply ends -- waits for all of it before its prefill starts. On Qwen3.8-27B ParoQuant int5 with DFlash2 on one R9700 that is about one decode step (34-53 ms) of TTFT on every back-to-back request (#225: 105 -> 139 ms); for 127 requests 1.12.0 ran 806 decode steps, all issued ahead, against 1.8.1's 680. Scheduler::step_next_locked, beside the other rules for issuing ahead and before the next step's KV is reserved, now issues nothing when the step just issued ends every request it carries: when it can bring each to its max_tokens (certainly with the token it emits, possibly with the drafts it verifies: output + 1 + drafts >= max_tokens), or, most likely, when those drafts hold an end-of-generation id (ignore_eos requests excepted). The engine hands the scheduler the end-of-generation ids at start (set_eog), the sorted list the card's acceptance reads. A guess that misses (a drafted end the verify rejects, too few drafts accepted to reach max_tokens) costs one step built after the commit instead of before it. Ends it does not predict still leave one step behind: an end the verify chose itself, a stop string, the context limit. Without a drafter only max_tokens ends are caught, exactly. At -v the commit names each request that ended with a step issued ahead behind it (finish reason, its last step's tokens and accepted drafts, output against max_tokens, whether its drafts held an end). Tests: sched_test pins both halves (a drafted end issues and reserves nothing; a request whose next token is its last, or whose token and accepted drafts could reach max_tokens, issues nothing; an ignore_eos request's drafted end, drafts without an end, and a request that every draft accepted would leave a token short still issue ahead; of two requests one going on, both issue ahead); the test of a request finishing under a step issued ahead now ends it on an end of text the scheduler cannot see coming. engine_e2e_test: two 32-token replies without a drafter are 62 decode steps, all issued ahead, not 64. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
55cf057a30
commit
f55570e351
5 files changed
+150
-3
No files matched your search
@@ -274,6 +274,10 @@ public:
|
||||
* cache. Takes the step lock because the step path inserts into the map (live sequences hold
|
||||
* their own block references). See IScheduler::reset_prefix_cache. */
|
||||
int64_t reset_prefix_cache();
|
||||
/* The vocabulary's end-of-generation ids, the ones the card's acceptance reads: step_next()
|
||||
* issues no step ahead behind one whose drafts end every request it carries. Set once at
|
||||
* start; none (the default) leaves only the max_tokens half of that rule. */
|
||||
void set_eog(std::vector<int32_t> ids);
|
||||
/* Forget one stored conversation, by label or engine id, keeping its first `keep_tokens`
|
||||
* (IPrefixCache::release_session). Refused with RAD_E_STATE while a request of that
|
||||
* conversation is queued or running: its blocks would be skipped as live and its close
|
||||
@@ -307,6 +311,8 @@ public:
|
||||
void expect_draft(uint64_t id, int n);
|
||||
const RadBatch* step_next();
|
||||
const RadBatch* step_next_locked();
|
||||
/* Whether the step just issued ends every request it carries (step_next_locked). */
|
||||
bool ends_every_request() const;
|
||||
void promote_next();
|
||||
/* Fold the step's outcome back in: append tokens, roll back rejected speculation, retire
|
||||
* finished requests, feed the draft controller. */
|
||||
@@ -475,6 +481,9 @@ private:
|
||||
* meta.n_layers; drafter layers bind from `base_layer` up) that the cache does not index?
|
||||
* Unlike a drafter hole, recomputing the tail cannot repair it; see admit_one. */
|
||||
bool hit_holes_trunk_ = false;
|
||||
/* The end-of-generation ids, sorted and unique (set_eog), and a lookup in them. */
|
||||
std::vector<int32_t> eog_;
|
||||
bool is_eog(int32_t id) const;
|
||||
/* R-SWA: the groups whose KV manager carries per-sequence runtime windows, with the W a
|
||||
* sequence is armed with (IKVManager::runtime_window_tokens). Empty for every model that does
|
||||
* not declare one, in which case admission and commit are exactly as before. A sequence with
|
||||
|
||||
Reference in new issue
Block a user