Inferensys

Glossary

Request Interleaving

Request interleaving is a fine-grained scheduling technique that multiplexes multiple inference requests with different characteristics on the same hardware to maximize utilization and improve fairness.
Developer testing AI inference on mobile phone in hand, laptop with optimization code visible, casual tech review moment.
CONTINUOUS BATCHING

What is Request Interleaving?

A fine-grained scheduling technique within continuous batching that multiplexes requests with divergent characteristics on the same hardware to improve utilization and fairness.

Request interleaving is an advanced iteration-level scheduling technique that allows an inference server to execute multiple requests with different priorities, sequence lengths, or service-level agreements (SLAs) within the same physical batch. Unlike basic dynamic batching, which groups requests at the batch level, interleaving schedules them at the granularity of individual model iterations. This enables new, high-priority requests to be inserted into a running batch, and long-running requests to be temporarily paused, minimizing idle cycles and head-of-line blocking to improve overall hardware utilization and responsiveness.

The technique operates by managing each request's state, such as its key-value (KV) cache, independently. A scheduler can interleave the decoding steps of a short, latency-sensitive query with the steps of a longer, background task. This is critical for optimizing GPU memory usage during the decoding phase, which is often memory-bound. By ensuring the hardware is always processing the most urgent work, request interleaving directly reduces tail latency (e.g., p99) and improves system fairness, making it a cornerstone of modern, high-performance inference servers like vLLM and TGI.

CONTINUOUS BATCHING

Key Characteristics of Request Interleaving

Request interleaving is a fine-grained scheduling technique within continuous batching that multiplexes requests with different computational demands on the same hardware to improve utilization and fairness.

01

Iteration-Level Scheduling

Unlike traditional batching which groups requests for an entire forward pass, request interleaving makes scheduling decisions per model iteration. This allows the scheduler to:

  • Dynamically adjust the active batch composition at each token generation step.
  • Insert new requests into the batch as soon as previous requests finish, eliminating idle cycles.
  • Remove completed sequences immediately, freeing resources for others. This fine-grained control is the core mechanism enabling high GPU utilization despite variable request lengths and arrival times.
02

Mitigation of Head-of-Line Blocking

A primary goal of interleaving is to eliminate head-of-line blocking, a major inefficiency in static batching. In a static batch, a single long sequence delays the completion of all other sequences in the batch. Interleaving addresses this by:

  • Allowing shorter sequences to complete and exit the batch independently.
  • Preventing long sequences from monopolizing batch slots for their entire duration.
  • Enabling new, potentially short requests to join the batch and be processed alongside the remaining long sequence. This results in dramatically improved tail latency (p95, p99) for interactive applications.
03

Optimization for Variable-Length Sequences

Request interleaving is specifically designed to handle the inherent variability in sequence lengths found in real-world inference workloads (e.g., different prompt lengths, generation limits). It optimizes for this by:

  • Using ragged tensors or specialized kernels to group sequences of different lengths with minimal padding overhead.
  • Balancing the computational load across iterations, as the effective 'batch size' in terms of total tokens is kept more constant.
  • This is a key advancement over variable-length batching, which reduces padding but still suffers from head-of-line blocking at the request level.
04

Separation of Prefill and Decode Phases

Interleaving treats the prefill phase and decode phase of autoregressive generation as distinct scheduling problems due to their different resource profiles:

  • Prefill (Compute-Bound): Processes the entire input prompt. The scheduler may batch multiple prefills together for high throughput.
  • Decode (Memory-Bound): Generates tokens iteratively. This is where interleaving is most active, managing many concurrent decoding sequences. The scheduler must efficiently manage the transition of requests from the prefill queue into the interleaved decode pool, ensuring both phases are optimally utilized.
05

Integration with KV Cache Management

Efficient interleaving is intrinsically linked to the management of the Key-Value (KV) Cache. As requests are interleaved, their cached attention states must be:

  • Dynamically allocated in GPU memory as new requests join.
  • Persisted and efficiently retrieved for the correct sequence at each iteration.
  • Swiftly evicted when a request completes to free memory for new requests. Poor KV cache management can negate the benefits of interleaving by causing excessive memory fragmentation or GPU out-of-memory (OOM) errors.
06

Core Objective: Maximizing GPU Utilization

The ultimate metric driving request interleaving is GPU utilization. It targets the reduction of idle cycles where streaming multiprocessors (SMs) have no work. It achieves this by:

  • Ensuring there is almost always a sufficient number of active sequences (in terms of total tokens) to keep the hardware saturated.
  • Overlapping memory-bound decoding operations with compute-bound prefill operations where possible.
  • Minimizing kernel launch overhead by maintaining persistent, optimally sized batches across iterations. This directly translates to higher throughput (tokens/second) and lower inference cost per request.
SCHEDULING COMPARISON

Request Interleaving vs. Other Batching Strategies

A technical comparison of how different inference batching strategies manage request grouping, execution, and resource utilization, focusing on latency and throughput trade-offs.

Feature / MetricRequest InterleavingStatic BatchingDynamic Batching

Scheduling Granularity

Iteration-level

Request-level

Batch-level

Batch Composition

Dynamic per iteration

Fixed for full request

Fixed per batch window

Handles Variable Sequence Lengths

Mitigates Head-of-Line Blocking

GPU Utilization During Decoding

90%

40-70%

70-85%

Typical P99 Latency Reduction

30-60%

Baseline

10-25%

Optimal For

Interactive, low-latency

Offline, high-throughput

Mixed workloads

Implementation Complexity

High

Low

Medium

CONTINUOUS BATCHING

Implementation in Inference Systems

Request interleaving is implemented within inference servers as a core scheduling policy, dynamically multiplexing requests with different characteristics to maximize hardware utilization and meet latency targets.

01

Scheduler Architecture

The scheduler is the central component that implements interleaving. It maintains a priority queue of active requests and makes fine-grained decisions at each model iteration. Key responsibilities include:

  • Request Admission: Evaluating incoming requests against system capacity and SLAs.
  • Iteration-Level Grouping: Determining which requests to execute together in the next forward pass.
  • Resource Arbitration: Managing contention for GPU memory (especially KV Cache) and compute cycles.
  • Completion Handling: Detecting when requests have finished generation and freeing their resources. This architecture moves beyond static or time-window dynamic batching to enable true iteration-level multiplexing.
02

KV Cache Management

Interleaving's efficiency is tightly coupled with Key-Value (KV) Cache management. Each request's attention states are stored in GPU memory during generation. The scheduler must:

  • Allocate Cache Slots: Dynamically assign portions of a fixed-size KV cache buffer to active sequences.
  • Handle Variable Lengths: Efficiently pack sequences of different lengths to minimize fragmentation.
  • Implement Cache Eviction: Apply policies (e.g., LRU - Least Recently Used) when the cache is full, potentially pausing requests or swapping states to CPU memory. Poor cache management under interleaving can lead to thrashing, where excessive cache swaps destroy the performance benefits.
03

Latency-Throughput Trade-offs

Interleaving allows operators to tune the scheduler along the latency-throughput Pareto frontier. Key levers include:

  • Maximum Batch Size: Limits how many requests can run concurrently per iteration, affecting throughput and iteration time.
  • Batch Timeout / Scheduling Window: How long the scheduler waits to accumulate requests, trading off tail latency for larger, more efficient batches.
  • Preemption Policies: Whether a new, high-priority request can pause a lower-priority one mid-generation, improving its latency at the cost of overall efficiency. The optimal configuration depends on the workload mix (e.g., chat vs. summarization) and Service Level Objectives (SLOs).
04

Integration with Continuous Batching

Request interleaving is the enabling mechanism for continuous batching (also called iteration-level scheduling). The system continuously:

  1. Joins: Injects new requests into the active set as soon as resources are available, without waiting for a batch to finish.
  2. Interleaves: Executes the mixed set of requests through a shared forward pass.
  3. Exits: Removes completed sequences from the active set and returns results immediately. This eliminates idle cycles and head-of-line blocking inherent in static batching, allowing the GPU to be nearly constantly utilized.
06

Challenges and Overheads

Implementing interleaving introduces system complexity and overheads:

  • Scheduling Overhead: The logic to select requests each iteration adds CPU-side computation.
  • Kernel Launch Overhead: More frequent, smaller batches can increase the relative cost of launching GPU kernels.
  • Complex State Management: Tracking the progress, cache location, and priority of dozens to hundreds of interleaved requests is non-trivial.
  • Fairness and Starvation: Without careful design, long-running requests can monopolize resources, causing short requests to wait excessively (starvation). Effective implementations use hybrid policies like shortest-job-first or weighted fair queueing.
REQUEST INTERLEAVING

Frequently Asked Questions

Request interleaving is a core scheduling technique in high-performance inference serving. These questions address its mechanisms, benefits, and practical implementation.

Request interleaving is a fine-grained scheduling technique that allows an inference server to multiplex the execution of multiple requests with different characteristics (e.g., sequence lengths, priorities) within a single batch at the granularity of individual model iterations. It works by treating the batch as a dynamic set of active sequences. At each decoding iteration, the scheduler selects a subset of sequences to execute based on factors like their current state and system load, allowing new requests to join the active set and completed ones to exit independently. This is a key enabler of continuous batching, breaking the rigid synchronization of static batching to dramatically improve GPU utilization and reduce tail latency.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.