Static batching, and where the capacity goes
The naive approach: collect B requests, run them together until all are done, then collect the next B.
The problem is that generation lengths vary enormously and are not known in advance. Real traffic has a heavy right tail — most responses are short, a few are very long. If your batch of 8 has lengths [20, 35, 40, 60, 80, 120, 200, 900], the batch runs for 900 steps. The sequence that finished at step 20 occupies a slot doing nothing for the remaining 880.
Quantify it. Utilization is mean length over max length:
total useful work = 20+35+40+60+80+120+200+900 = 1455 sequence-steps
slots x steps = 8 x 900 = 7200 sequence-steps
utilization = 1455 / 7200 = 20.2%
Four fifths of your paid-for capacity produced nothing. And this is not a contrived example — a lognormal length distribution with a realistic tail gives numbers in this range routinely. The larger the batch, the worse it gets, because max over more samples reaches further into the tail. Static batching is one of the few optimizations that gets worse as you scale it up.
There is a second cost that is easy to miss: padding. Sequences in a static batch must be padded to a common length for the tensors to be rectangular. Attention over padding positions is wasted arithmetic, and the padding also sits in the KV cache consuming memory that could have held real sequences.
Orca's contribution begins with noticing that the padding problem and the early-finish problem have the same root cause — treating a batch as a fixed rectangular object with a lifetime.
STATIC BATCH, 8 slots, batch runs until the longest finishes
slot 0 ####································································
slot 1 ######······························································
slot 2 #######·····························································
slot 3 ##########··························································
slot 4 #############·······················································
slot 5 ####################································
slot 6 #################################···································
slot 7 ####################################################################
^ useful work ^ idle slot, still allocated, still costing you
utilization = 20.2%
REMEMBERA static batch runs until its longest member finishes, so every shorter sequence leaves its slot idle for the remainder.