Inference systems · Research feature

Smaller, Similar-Prefix Batches Outperform Larger, Diverse Groups in LLM Inference

A new study finds that tightly matched request prefixes in large language model inference improve performance over larger, mixed batches.

Adapted from research by Saksham Rathi, Preeti, Mythili Vutukuru.

arXiv preprint revision · 2026-10-17 · Attribution & reuse
In this article
Editorial illustration of optical fibers.

Editor’s introduction

The study evaluates batch sizing in large language model inference, focusing on prefix homogeneity—the degree to which requests share a common initial sequence. The study introduces Feather, a prefix-aware scheduler using reinforcement learning to balance batch size and homogeneity, and a lightweight Chunked Hash Tree for faster prefix detection. Results show Feather achieves 2–10X higher throughput in specific workloads by minimizing KV cache accesses, without degrading performance when prefix sharing is limited.

Introduction

Large language models (LLMs) are rapidly transforming modern computing, powering applications such as conversational assistants, code generation, and retrieval-augmented generation. As these models transition from research to production, cloud AI engines must improve serving latency and resource efficiency for both online and offline inference. While prior work has proposed scheduling strategies, parallelization techniques, memory management methods, quantization, and kernel-level optimizations, efficiently serving LLM workloads, especially under realistic high-throughput conditions, remains an open problem.

GPU Execution Model

GPUs are hierarchically organized for parallelism across hundreds of thousands of threads. The basic compute unit is the Streaming Multiprocessor (SM), and modern GPUs typically contain a few hundred SMs. Each SM includes an L1 cache, shared memory, tensor cores for matrix multiplication (GEMM), and execution units. SMs access global memory through a shared L2 cache. This hierarchy, from small, fast on-chip memory to large, high-latency global memory, is critical for LLM serving, as KV cache access patterns directly influence memory bandwidth utilization. Like CPUs, GPUs use hardware prefetching and benefit from regular, sequential memory access patterns.

Batching and Scheduling

vLLM adopts a first-come, first-served (FCFS) scheduling policy as a practical baseline for LLM serving. Sarathi-Serve reduces prefill-decode interference through chunked prefills and stall-free batching, while DistServe eliminates it by disaggregating the two phases across GPUs. At the kernel level, POD-Attention overlaps prefill and decode on a single GPU via fused attention with SM-aware scheduling, and Bullet enables fine-grained resource sharing through dynamic SM allocation. At the request level, BucketServe groups requests by sequence length to improve batching efficiency, and dynamically adapts the batch size to runtime constraints. Complementary to prior work, Feather operates at the scheduler level and learns when to stop batch construction based on prefix homogeneity, introducing a scheduling signal not explicitly exploited in existing systems.

Motivation

Through a set of controlled experiments (here and in §A), we validate three hypotheses that underpin the design of Feather: (i) prefix homogeneity, the extent to which all requests in a batch share a common prefix, has a strong impact on the decode throughput because it increases the locality of KV cache accesses. Importantly, these gains can be achieved without any modifications to existing attention kernels. (ii) There is a trade-off between batch size and prefix homogeneity, where moderately sized homogeneous batches can outperform large heterogeneous batches; and (iii) existing prefix detection approaches incur substantial CPU overhead.

Experimental Setup

All experiments use the Llama 3 8B model and are run on an RTX 6000 Ada GPU with 48 GB of GDDR6 memory and a 96 MB L2 cache. We use the vLLM inference engine with a default maximum batch size of 500 unless stated otherwise. We first focus on decode throughput, measured in output tokens per second. To isolate decode behavior, we perform a warm-up run so that the prefix KV caches are resident in GPU memory. This ensures that per-token compute remains constant within an experiment and differences arise primarily from memory accesses and batching. We also report end-to-end throughput, which includes the time taken to prefill the queries. For this model, a 10k-token request generates 1.2 GB of KV cache data across all layers. Within each layer, vLLM uses its paged memory management system and allocates the KV cache in blocks of 16 tokens contiguously in GPU memory, which is sufficient for locality benefits to kick in. We sample requests from the L-Eval dataset and prune the size of each request as required by the experiment. We use the same FlashAttention backend (FlashAttention-2, via vLLM 0.13.0) throughout all the experiments, so that observed throughput differences are attributable only to batch composition rather than kernel-level variation.

Significance of Prefix Homogeneity

We start by observing the impact of prefix homogeneity on decode phase throughput. When all requests in a batch share a common prefix, their attention operations traverse the same KV cache regions concurrently. This yields two beneficial effects: (i) spatial locality: Sequential access to contiguous KV tensors enables the hardware prefetcher to fetch upcoming cache lines from DRAM into L2; (ii) temporal locality: Cache lines fetched for one request are reused by neighboring requests before eviction. Together, these effects increase L2 hit rates and DRAM utilization, improving throughput. In contrast, heterogeneous prefixes interleave KV accesses across disjoint regions, disrupting locality and reducing effective memory bandwidth. We will now present experiments that validate these claims.

Batch Size vs Prefix Homogeneity

So far, we have established that prefix homogeneity has a significant impact on performance. But when the workload does not have enough requests from a prefix group and prefix-homogeneous batches are too small, the compute will remain under-utilized, leading to a loss in throughput. Therefore, there exists a trade-off between batch size and prefix homogeneity. We now explore this trade-off.

Overhead of Dynamic Prefix Detection

Next, we study how state-of-the-art inference engines identify prefix sharing and the costs involved. Systems such as SGLang and BatchLLM do not explicitly form prefix-homogeneous batches, but use radix trees to detect sharing, and schedule requests to minimize KV recomputation.

Design and Implementation

Our experiments so far have demonstrated that the length of the prefix shared across all active requests is an important determinant of system performance. However, this metric interacts with batch size in a complex way: larger batches improve GPU utilization but often reduce shared prefix alignment. Further, detecting this shared prefix length incurs high overhead in existing systems. We now describe the design of Feather, an efficient scheduler that finds the right balance between batch size and prefix homogeneity.

Key Idea 1: Learn the Stopping Decision via RL (§4.3)

The trade-off between batch size and prefix homogeneity raises a key question: when should the scheduler stop adding requests? The answer depends on both hardware and workload, making fixed heuristics brittle. We model batch construction as a sequential decision process and learn a stopping policy via Reinforcement Learning. At each step, the scheduler evaluates a candidate request using various state features and decides whether it should be added to the batch or if the batch should be dispatched to the GPU for execution.

Batching and Reinforcement Learning

The CHT efficiently identifies the next best request to add, maximizing shared prefix length, but it does not determine when to stop. While adding requests improves GPU utilization, it can also shrink the shared prefix and degrade locality. We frame this stop/continue decision as a learning problem and present three policies: a heuristic, a contextual bandit, and a Q-learning agent. The scheduler incrementally builds a batch by selecting candidates via the CHT and deciding whether to admit them or dispatch the batch.

State, Actions, and Reward

We choose decode throughput as the reward because it is effectively the inverse of time between tokens (TBT), while remaining a safer objective than minimizing TBT directly — a batch of size one trivially minimizes per-token latency without regard for GPU utilization, so a raw TBT-minimizing policy would degenerate toward starving the batch. Time to first token (TTFT) is also a weaker signal for this decision, as it is dominated by prefill compute and queuing delay rather than by the decode batch composition choice the policy makes at each step. Finally, decode throughput implicitly captures hardware and model-specific effects — such as attention cost scaling and memory bandwidth limits — that are not exposed as explicit state features, allowing the same reward formulation to generalize across the configurations in §5 without redesigning the state space.

Heuristic Policy

As a baseline, we encode domain intuition as simple rules balancing two goals: maximizing GPU utilization (large batches) and preserving prefix locality (avoiding large drops in the shared chain). The heuristic always accepts candidates with zero chunk loss (free additions). When the batch is small, it tolerates higher loss to avoid underutilization. Otherwise, it admits a candidate only if the chunk loss is within a fixed threshold, with slightly relaxed tolerance when many waiting requests share the resulting prefix (anticipating amortization). If none of these conditions hold, it stops and dispatches the batch. This policy requires no training and converges immediately, but its fixed thresholds cannot adapt to workload or hardware changes.

Models and Hardware

We evaluate three model families across multiple sizes: Qwen 0.5B, 1.5B, 8B, LLaMA 3 8B, and LongChat 13B. Experiments are run on an NVIDIA RTX 6000 Ada GPU with 48 GB GDDR6, 96 MB L2, and the maximum batch size is fixed at 500, which fits within the GPU memory for most settings. We additionally evaluate on an A100-80GB GPU for comparisons involving PAT, as it is specifically optimized for this hardware.

Workloads

Following prior work, request arrivals are modeled as a Poisson process, with length pruning applied as required by each experiment. L-Eval is a benchmark of human-labeled query–response pairs spanning tasks such as summarization and question answering, with sequence lengths ranging from 2.7K to 210.5K tokens. LongBench is a collection of long-context samples across six task categories: multi-document QA, summarization, and code completion, with context lengths between 4K and 10K tokens.

Baselines

We compare Feather against state-of-the-art LLM serving systems, all with prefix caching enabled. vLLM uses its default FCFS scheduling policy. SGLang is evaluated under FCFS, LPM, and DFS-W to cover its design space. We also evaluate DynamicBatching and PAT, both implemented on top of vLLM: DynamicBatching adjusts batch sizes based on runtime memory utilization and latency constraints, while PAT is a prefix-aware attention kernel that reduces redundant KV cache accesses via query packing. Feather operates purely at the batch formation layer and is agnostic to how prefill tokens are scheduled, so it composes naturally with chunked-prefill and prefill-decode multiplexing techniques such as Sarathi-Serve. Chunked prefill is enabled by default in vLLM, the backend used throughout our experiments unless otherwise noted.

End-to-End Comparison: Feather vs Baselines

We evaluate a workload where the default configuration has 5 prefix groups, each 5K tokens long, with roughly equal request distribution, a request rate of 100 req/s, and 200 output tokens per request. Such workload configurations are common in prior work evaluating LLM serving systems. We vary these parameters to examine how Feather compares to the baselines. We also evaluate workloads without prefix sharing and show Feather performs on par with FCFS. The token budget is 32K tokens. For Feather’s RL policy, we find that bandit and Q-learning approaches perform similarly across most settings; unless stated otherwise, we report results using the bandit policy.

Workloads with No Prefix Sharing

We next evaluate Feather and compare it against other scheduling policies on a workload without prefix sharing; that is, no two requests share a common prefix. Figures 22 and 22 report throughput and time between tokens (TBT) across a range of input rates. At higher input rates, vLLM-based policies begin to outperform SGLang policies, primarily due to their ability to form larger batches. Notably, even in the absence of prefix sharing, Feather, powered by its adaptive RL-based policy—matches the performance of vLLM’s FCFS scheduler. In contrast, SGLang policies achieve lower TBT, which can be attributed to their smaller batch sizes.

Effect of Chunk Size

Figures 25(a) and 25(b) show CPU overhead and throughput across shared prefix lengths for different chunk sizes in Feather’s CHT. Increasing the chunk size reduces CPU overhead by enabling coarser-grained matching; a chunk size of 1 is equivalent to an exact radix tree. Overhead rises with prefix length due to more hash comparisons, while throughput declines due to higher KV cache memory pressure. At larger prefix lengths, the overhead gap between chunk size 1 and larger sizes widens substantially, yet throughput remains similar across all chunk sizes, suggesting that the CPU scheduling cost, even at the finest granularity, is not the primary bottleneck in our CHT. Overall, CHT is robust against chunk size selection, and even its radix tree-equivalent configuration (chunk size 1) achieves significantly better efficiency than a conventional radix tree.

Conclusion

In this paper, we showed that maximizing batch size alone is not sufficient for efficient LLM serving during the decode phase. Instead, we identified prefix homogeneity, the extent of the prefix shared across all requests in a batch, as a more important factor for improving memory locality and reducing redundant KV cache accesses. Higher batch sizes lead to better GPU utilization but also reduce the length of the prefix shared across all requests. Existing approaches ignore this aspect and also rely on expensive prefix detection mechanisms that introduce significant CPU overhead. To address these gaps, we proposed Feather, a lightweight prefix-aware scheduler that balances this trade-off between batch size and prefix homogeneity. It uses a Chunked Hash Tree (CHT) for fast prefix detection and a reinforcement learning-based batching policy that decides when to stop batch formation based on the loss in prefix homogeneity due to the addition of a new request. Our results show that Feather consistently improves end-to-end throughput across diverse workloads while keeping scheduling overhead low. As future work, we plan to extend this approach to distributed and multi-GPU settings. We are also looking into more adaptive and lightweight learning policies that can improve robustness across different workloads and deployment scenarios.

A.1. Effect of Total KV Cache Size

Another question to ask if the high throughput values are correlated with the entire KV cache working set fitting into one of the cache levels. L1 cache size is typically in KBs, which is too small even for tens of tokens. Therefore, we focus on the L2 cache, which is 96 MB in size for the GPU on which these experiments were run. In the top-left region of the heatmap, the entire KV cache fits within this size. However, no clear throughput degradation is observed once this threshold is exceeded. This indicates that effective spatial and temporal locality depend more on whether the subset of KV blocks actively accessed by batched requests at a given time (i.e. the dynamic working set) fits in the L2 cache. It is intuitive that this dynamic working set is smaller in size for prefix-homogeneous batches which explains the higher throughput gains achieved for such batches. Moreover, even for such a small model, the model weights are already large enough to prevent the entire KV cache to reside in L2. Therefore, performance gains due to prefix homogeneity primarily stem from a smaller dynamic working set of the KV cache.

B.5. Adding a Request to the Active Batch

Given a request with its prefix-hash vector, the AddToBatch procedure promotes it to the active set (line 1) and updates the working set, reference counts, and other metadata in a single backward pass over the prefix-hash vector. For each level, if the reference count of the corresponding hash is zero (no other active request shares it), the level-hash tuple is inserted into the working set, and all corresponding waiting requests have their miss counts decremented and are reinserted into the waiting heap (lines 7-12). The reference counts are incremented at all levels (line 14). In parallel, the shared prefix tip is recomputed by tracking the deepest level at which the level-hash tuple remains in the working set; the first such match during the backward traversal determines the new tip (lines 15-17), while the loop continues to ensure that all state updates are applied. If this is the first active request, the tip is initialized directly to the end of its prefix-hash vector.