Orca Iteration-Level Dynamic Batching
Orca · OSDI 2022 · Medium · 40 minutes
Admit requests into free slots each iteration and release them immediately on completion.
Discrete generation replay after prefill, with unit-duration iterations and one token per active request; selective-batching operators are outside this kernel.
Functions to implement
iteration_schedule(arrivals: list[int], lengths: list[int], capacity: int) -> tuple[list[tuple], list[int]]
Orca Iteration-Level Dynamic Batching
1. Problem
Admit requests into free slots each iteration and release them immediately on completion.
Discrete generation replay after prefill, with unit-duration iterations and one token per active request; selective-batching operators are outside this kernel.
Source: Orca: A Distributed Serving System for Transformer-Based Generative Models · Section 3, S1 and Figure 4: iteration-level scheduling; Section 4.2, Algorithm 1: FCFS admission.
2. Core equations
$$ C_i=1+\max{t:i\in B_t},\qquad |B_t|\le K,\qquad \sum_t\mathbf{1}[i\in B_t]=L_i. $$
3. From equations to code
iteration_schedule(arrivals: list[int], lengths: list[int], capacity: int) -> tuple[list[tuple], list[int]]— Per-iteration active request IDs and completion times in original order.
Track remaining tokens. Admit ready pending requests before executing, decrement active requests afterward, and immediately release completed slots. Admission does not wait for the slowest member of the old batch.
4. Conventions
arrivals and lengths are equal-length integer lists; arrivals>=0, lengths>=1, capacity>=1. Break arrival ties by input index. Fill slots at each iteration boundary in (arrival,index) order without preempting active requests. Completion is the end of the final occupied slot. Return (batches, completion_times), preserving idle slots as empty tuples.
5. Experiment view
Replay six simultaneous requests of unequal length, compare completions with request-level fixed batches, and sweep capacities 1, 2 and 3 for latency and slot occupancy.
The chart is generated by the actual submitted kernel during T3 and by the reference during export. Values are synthetic teaching measurements, not GPU throughput or full-model quality claims.
6. Run your implementation
Complete the functions in the Python editor on the right, then click Run tests. Inspect each failed check, update your implementation, and run again. Passing every required check marks the problem as solved and unlocks the notes.
7. Further study
Read the cited section and explain which dimensions or scheduling constraints the kernel preserves. Then extend the experiment beyond the stated fixture while retaining the existing contract. Larger models, real devices, and communication costs require separate measurement.