Repository navigation
scheduler: queue a first chunk behind a prefill in flight (ATLAS_PREFILL_QUEUE_FIRST_CHUNK, default-off, ported from Enntity) - #226
Merged
Conversation
Contributor
Author
This was referenced Oct 28, 2026
1 of 4 tasks
AzeezIsh
force-pushed
the
stack/qwen-mtp-absorb
branch
from
October 29, 2026 04:44
02e5aec to
b1ba01e
Compare
AzeezIsh
force-pushed
the
stack/qwen-queue-first-chunk
branch
from
October 29, 2026 04:44
a1dab65 to
853445e
Compare
AzeezIsh
force-pushed
the
stack/qwen-mtp-absorb
branch
from
October 29, 2026 07:12
b1ba01e to
71f6030
Compare
AzeezIsh
force-pushed
the
stack/qwen-queue-first-chunk
branch
from
October 29, 2026 07:12
853445e to
31a9803
Compare
… prefill in flight
Every new prompt ran its first chunk at admission, ahead of the remaining
chunks of the prompts already prefilling. Four ~18K-token prompts arriving
a second apart at 16K-token chunks (qwen4_exp TP2/EP2) ran all four first
chunks before any 1.7K-token tail: first tokens 16-18.5 s after the first
arrival for all four, where FIFO prefill gives 5.6/10.2/14.7/19.3 s.
With ATLAS_PREFILL_QUEUE_FIRST_CHUNK=1 (default off) on a multi-rank
world, a prompt admitted while a prefill is in `prefilling` does its setup
(grammar, sequence, the worker's MTP fence, vision state and shared-prefix
plant) but no chunk and no prefill command, and joins the queue at its
`queue_order` position with `queued_first_chunk = Some(len)`. The continue
phase runs that chunk when the prompt is the head: the inline chunk's
command, `prefill_chunk` from 0, first-chunk normalization and failure
handling, never the two-phase prefill (which sends the worker nothing).
The head sends each chunk command right before running that chunk, so the
worker runs every prompt's chunks in the head's order.
`start_chunked_prefill` takes `FirstChunk::{Inline, Defer, Queue}` instead
of `defer: bool`. Deferrals (co-dispatch, VARLEN, always-mixed fuse,
multi-prompt prefill) keep precedence; image prompts and beam searches keep
the inline chunk; nothing in flight means inline, as before. A queued
streaming request whose client is gone leaves the queue before its first
chunk (freed on every rank, no prefill command sent). Off, the scheduler
sends and runs exactly what it did.
Not built or run on hardware yet.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 5eeeb1a of Enntity/atlas; hand-resolved:
prefill_a_step.rs keeps our FirstChunk param and its deferred branch was
rewritten to first_chunk != Inline / == Defer / == Queue rather than the
upstream bool; the shared phase/queue_first files land in the dc896cc and
f1cc7cb commits that complete them)
ATLAS_PREFILL_QUEUE_FIRST_CHUNK queued every prompt admitted behind a prefill in flight, including one that fits a single chunk: with SRPT off it went to the back and waited behind every remaining 16K chunk of a long prompt (tens of seconds behind a ~200K prefill), where without the lever it finishes at admission. queue_first::first_chunk now takes one_chunk (the prompt fits the admission's chunk budget: start_chunked_prefill's first chunk is then the whole prompt), and such a prompt keeps the inline chunk. The SRPT test's short newcomer is now an 18-token (two-chunk) prompt; a new test pins a 3-token prompt behind a 200-token prefill running at admission, SRPT on or off. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit dc896cc of Enntity/atlas; these files carry the 5eeeb1a and dc896cc hunks together -- their queue_first_chunk.rs hunk is in 7fd2412's commit, which creates that file)
The queued first chunk sent its command and ran the chunk itself, so an agreed KV refusal failed the request, where every later chunk goes through prefill_chunk_with_preemption and evicts a decoding sequence. By the time a queued chunk runs it competes with the sequences decoding beside it exactly as a later chunk does, so it now takes that path from offset 0 (the same 0xFFFFFFF0 command words) before the first-chunk normalization; a final refusal still fails only its request. Its record/stream-wait errors are logged like the inline path's instead of dropped. Tests: a retryable refusal preempts the decoding request and reruns the chunk; a final one fails only the queued request; a shared-prefix plant reaches the worker at admission and the chunk command when the chunk runs. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit f1cc7cb of Enntity/atlas)
The real start and continue phases against `PreemptStubModel` (now with a plain multi-rank switch, `ep`), asserted on the chunks the head runs and on the EP worker's command words: - a newcomer behind a prefill in flight waits for its tail, and its chunk-0 command reaches the worker only when the head runs that chunk (never the whole prompt at once: no two-phase prefill); - off by default, the first chunk runs at admission exactly as before; - one GPU keeps the inline first chunk with the lever on; - a burst admitted with nothing in flight runs its first chunks in arrival order; - SRPT puts a short tail ahead of a new long prompt, and a short newcomer ahead of a long remainder; - a queued buffered or streaming request whose caller left is freed on every rank with no prefill command sent; - a refused queued first chunk fails only its request, as an inline one does. Not compiled or run yet (the Mac cannot build the CUDA crates). Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 7fd2412 of Enntity/atlas)
One-line // Ported from Enntity/atlas <shas> (AGPL-3.0-only) credits; plain comments, not module docs.
…the apply order Upstream order was 5eeeb1a -> 7fd2412 -> dc896cc -> f1cc7cb, but I applied 7fd2412 last, so dc896cc's and f1cc7cb's hunks to preempt_tests/ queue_first_chunk.rs silently dropped. The file is now f1cc7cb's content (admit_planted, the 18-token SRPT case, the one-chunk-at-admission case, the KV-refusal preemption case). Production files verified byte-identical to upstream f1cc7cb apart from credit lines.
AzeezIsh
force-pushed
the
stack/qwen-mtp-absorb
branch
from
October 29, 2026 07:30
71f6030 to
74f0f29
Compare
AzeezIsh
force-pushed
the
stack/qwen-queue-first-chunk
branch
from
October 29, 2026 07:30
31a9803 to
a068da0
Compare
AzeezIsh
marked this pull request as ready for review
October 29, 2026 07:39
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack: main ← #198 ← #223 ← #224 ← this. 6 commits, ported from Enntity/atlas (AGPL-3.0:
5eeeb1a,7fd2412,dc896cc,f1cc7cb) with credit lines.Summary
Measurements (vs its parent, receipts on #216;
git range-diffis=for all 6 commits)Test plan
queue_first16/16,preempt49/49Tracking: #220, #216.
Generated with Devin