← All questions
Inference & ServingHard· Latency· Prefill· Generation

If prefill is compute-limited and generation is memory-...

When a large prefill request arrives, it consumes significant GPU compute resources, which can block the memory-bound generation tasks of other requests. This causes noticeable spikes in inter-token latency (ITL). To mitigate this, chunked prefill limits the number of prefill tokens processed in a single step, allowing the GPU to interleave prefill and generation. Tools like FlashAttention-2 support this via the varlen interface, which handles mixed sequences in a single kernel call, slightly increasing TTFT while significantly improving ITL stability.

Code playground (Python)