Introduction
Serving Large Language Models (LLMs) to thousands of concurrent users requires sophisticated scheduling to ensure fairness. Current systems often employ preemption to meet latency targets for high-priority requests. When a high-priority task arrives, the system pauses lower-priority ones, swapping their Key-Value (KV) cache from GPU to CPU memory. However, state-of-the-art systems like vLLM suffer from a significant "efficiency gap" during this context switching process.
The authors identify three primary bottlenecks in existing systems:
- I/O Underutilization: Moving thousands of tiny, non-contiguous memory blocks (e.g., 16 tokens) over the PCIe bus incurs massive software overhead due to the API dispatch time for each transfer.
- GPU Idleness: The GPU often remains idle while waiting for host-side memory management and data transfers to complete.
- Redundant Transfers: Multi-turn conversations often involve repeatedly swapping the entire conversation history, even when much of that data remains unchanged.
FastSwitch System Architecture
FastSwitch addresses these bottlenecks through a redesigned serving architecture that prioritizes I/O efficiency and asynchronous execution.
The system introduces three core architectural optimizations:
- Dynamic Block Group Manager: Instead of managing individual 16-token blocks, it groups contiguous blocks into larger "Block Groups" (e.g., ~1,000 tokens) using a buddy allocator logic. This maximizes PCIe throughput by reducing the number of API calls without sacrificing the memory-saving benefits of paged attention.
- Multithreading Swap Manager: By offloading memory transfers to a dedicated C++ thread pool, FastSwitch bypasses the Python Global Interpreter Lock (GIL), allowing I/O operations to overlap seamlessly with GPU computation.
- KV Cache Reuse Mechanism: This tracks conversation history in CPU memory, ensuring that during a context switch, only the newly generated tokens are swapped, significantly reducing the total volume of data moved.
Optimizing Memory Transfers
The shift from fixed-size blocks to dynamic block groups is central to FastSwitch's performance. In traditional systems, the overhead of launching thousands of cudaMemcpyAsync calls for tiny blocks can exceed the actual data transfer time.
As shown in the timeline comparison, grouping blocks allows for larger, more efficient transfers. This reduces the time the host spends dispatching commands and allows the GPU to resume computation much sooner, effectively closing the efficiency gap.
Evaluation and Results
The researchers evaluated FastSwitch using the ShareGPT dataset on LLaMA-8B and Qwen-32B models, utilizing NVIDIA A10 and A100 GPUs. FastSwitch was compared directly against vLLM (v0.3.3).
Key results include:
- Tail Latency Reduction: FastSwitch achieved speedups of 1.4× to 11.2× in tail latency (P95, P99, P99.9) for both Time to First Token (TTFT) and Time Between Tokens (TBT).
- Throughput Gains: Overall request throughput increased by up to 1.44×.
- Data Reduction: The KV Cache Reuse mechanism reduced the total number of blocks swapped out by 53% in multi-turn scenarios.
- Minimal Overhead: Despite the complexity of C++ multithreading, the management overhead remained under 1% of the total end-to-end time.
Conclusion
FastSwitch demonstrates that the bottleneck in modern LLM serving is often the software overhead of managing fine-grained memory rather than the physical limits of hardware. By introducing coarse-grained dynamic memory management and asynchronous C++ multithreading, FastSwitch enables highly efficient, fairness-aware scheduling. Future work includes extending these optimizations to multi-GPU and multi-node environments.
Summary updated