The scheduler
Two lists, one GPU, one choice per step.
Ch. 5 Step 9 ended here: a newcomer's prefill stretching everyone's decode step. SGLang doesn't run the two together by default. They split the work into two kinds of batch and pick one each step. That's the scheduler.
The scheduler’s arithmetic, once
A prefill batch of tokens takes about ; a decode step takes . With prefill-first, a newcomer gets and everyone else sees a gap of that plus one decode step. Capping prefill batches at tokens and alternating gives
Mixing a chunk of into each decode step removes the gap entirely and gives .
In SGLang, schedule_policy orders the waiting list, and the loop above is Scheduler.get_next_batch_to_run(), which tries to build a prefill batch first and falls back to the running decode batch. chunked_prefill_size caps a prefill batch and is on by default (8,192 tokens on an H100), but a prompt that is partway through its chunks gets its next chunk on the very next step, so on its own it does not shorten the freeze. --prefill-decode-interval N runs decode steps after every prefill batch, and gives the alternation in step 6. --enable-mixed-chunk turns on mixing; the chunk and the decodes then share one budget, so = chunked_prefill_size .