SpotServe: Serving Generative Large Language Models on Preemptible Instances

Xupeng Miao, Chunan Shi, Jiangfei Duan, Xiaoli Xi, Dahua Lin, Bin Cui, Zhihao Jia

SpotServe: Slashing LLM Hosting Costs with Smart Spot Instance Management

TL;DR

SpotServe is the first distributed serving system designed to run generative Large Language Models (LLMs) on "preemptible" (spot) cloud instances, which are up to 90% cheaper but can be reclaimed by providers at any time. By using dynamic model reparallelization and token-level state recovery, SpotServe reduces tail latency by up to 9.1x and cuts monetary costs by 54% compared to traditional on-demand hosting.

What Problem Does This Paper Address?

Generative LLMs like GPT-4 or LLaMA are notoriously expensive to serve because they require massive amounts of GPU memory and compute. Cloud providers offer "spot instances"—spare capacity sold at a massive discount—but these come with a catch: the provider can "preempt" (shut down) your server with only a few seconds' notice.

Standard LLM serving systems aren't built for this volatility. If a node in a parallelized inference pipeline is snatched away, the entire pipeline usually crashes. Existing solutions either restart the request from scratch (wasting compute) or reroute it to another server (causing massive latency spikes). Furthermore, reloading a 100B+ parameter model from disk can take minutes, making "just restarting" a non-starter for real-time applications.

Methods

The authors introduce SpotServe, which treats instance availability as a dynamic variable rather than a static constraint. Its architecture relies on three main pillars:

  1. Parallelization Controller: This component monitors the current pool of available spot instances. It uses a hybrid optimization algorithm to choose the best parallelization strategy—balancing data, tensor, and pipeline parallelism—to maintain high throughput and low latency as the number of GPUs fluctuates.
  2. Context-Aware Device Mapping: When the number of instances changes, SpotServe must "re-parallelize" the model. Instead of a fresh start, it formulates the transition as a bipartite graph matching problem. Using the Kuhn-Munkres (KM) algorithm, it maps new physical GPUs to logical model stages in a way that maximizes the reuse of model weights and KV caches (the "memory" of previous tokens) already residing in GPU memory.
  3. Stateful Inference Recovery: Most cloud providers offer a short "grace period" (e.g., 30 seconds) before a spot instance is killed. SpotServe uses a "just-in-time" (JIT) scheduler to commit inference progress at the token level rather than the request level. It uses the grace period to finish as many tokens as possible and proactively migrate the KV cache to surviving nodes.

Datasets

The researchers evaluated SpotServe using three popular LLMs: OPT-6.7B, GPT-20B, and LLaMA-30B. To simulate real-world conditions, they used:

  • AWS g4dn spot preemption traces: Real-world data showing when and how often instances are reclaimed.
  • MAF (Microsoft Azure Functions) trace: A production workload trace used to simulate fluctuating user request rates.
  • Hardware: Evaluations were performed on AWS g4dn.12xlarge instances (NVIDIA Tesla T4 GPUs).

Key Insights and Ideas

  • The Autoregressive Advantage: Because LLMs generate text one token at a time, every token is effectively a checkpoint. SpotServe exploits this by treating the KV cache as the primary state to be saved, allowing a request to "teleport" from a dying node to a new one without re-processing the entire prompt.
  • Migration Overlap: The system doesn't wait for a full migration to finish before starting work. By prioritizing the migration of "front" model layers, the first stages of the pipeline can begin serving while the later stages are still receiving data.
  • Proactive vs. Reactive: Unlike baselines that wait for a crash to happen, SpotServe uses cloud preemption notifications to trigger a "graceful exit," turning a potential system failure into a planned reconfiguration.

Key Results

  • Latency: Compared to the best existing LLM serving systems, SpotServe reduced the P99 tail latency by 2.4x to 9.1x. This means users experience far fewer "hangs" when servers are swapped out.
  • Cost: SpotServe achieved a 54% reduction in monetary cost compared to using stable on-demand instances, while maintaining comparable average latency.
  • Efficiency: The system can handle "bursty" workloads more effectively than static systems because it can dynamically scale its parallelization strategy up or down as spot instances become available or are reclaimed.

Limitations and Future Work

  • Grace Period Dependency: SpotServe’s efficiency is tied to the length of the cloud provider's grace period. If a provider were to kill instances instantly without notice, the "stateful recovery" would be less effective.
  • Homogeneous Instances: The current implementation focuses on clusters of the same GPU type. The authors note that extending this to heterogeneous clusters (mixing different GPU types) is a promising but complex future direction.
  • Preemption Prediction: While SpotServe reacts to cloud signals, it does not yet use machine learning to predict when a preemption might happen based on historical trends, which could further optimize migration timing.

Summary updated

BibTeX
@inproceedings{miao2024spotserve,
  author = {Xupeng Miao and Chunan Shi and Jiangfei Duan and Xiaoli Xi and Dahua Lin and Bin Cui and Zhihao Jia},
  title = {{SpotServe: Serving Generative Large Language Models on Preemptible Instances}},
  booktitle = {ASPLOS},
  year = {2024},
  doi = {10.1145/3620665.3640411},
}
Figure