A long prompt's prefill run in one shot can take far longer than a single decode step for other concurrently running requests — those requests effectively stall until the huge prefill finishes, spiking their inter-token latency. Simulate chunked prefill scheduling: a long prompt's prefill is split into fixed-size chunks and interleaved with ongoing decode steps for other requests, instead of running the entire prefill in one uninterrupted burst.
budget_left = token_budget - n_active_decode_requests -- 1 token-unit per active decode request
chunk_size = min(budget_left, tokens_left_in_prefill) -- spent on the next prefill request in FIFO order
(arrival_step, request_id, prefill_tokens) — after finishing prefill each produces exactly n_decode_tokens_each output tokens (a shared constant across all requests) before completing.chunk_size tokens each.Reserve exactly 1 token-unit of budget per currently active decode-phase request BEFORE touching any prefill chunk, every single step. Once a prefill request's remaining tokens hit 0, it transitions to a decode-phase request starting the NEXT step (it does not get a decode token in the same step its prefill finishes).
No results yet
Run your code to check it against the examples, or submit to run every test.