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
@@ -30,6 +30,8 @@ int Engine::step_state_init() {
|
||||
if (vocab_) eog = vocab_->eog();
|
||||
std::sort(eog.begin(), eog.end());
|
||||
eog.erase(std::unique(eog.begin(), eog.end()), eog.end());
|
||||
/* The scheduler's rule for a step that ends its requests reads the same ids (step_next). */
|
||||
sched_.set_eog(eog);
|
||||
const int64_t n_slot = cfg_.max_seqs > 0 ? cfg_.max_seqs : 1;
|
||||
const int64_t slot_bytes = n_slot * (int64_t)sizeof(StepSlot);
|
||||
for (auto& rk : ranks_) {
|
||||
|
||||
Reference in new issue
Block a user