SAIR: Cost-Efficient Multi-Stage ML Pipeline Autoscaling via In-Context Reinforcement Learning

Jianchang Su, Yifan Zhang, Shengkai Lin, Shizhen Zhao, Yusheng Zheng, Yiwei Yang, Wei Zhang

TL;DR

Scaling modern multi-stage ML serving pipelines is like playing whack-a-mole: speed up one stage, and the bottleneck instantly migrates downstream. While traditional autoscalers lack pipeline-wide vision and deep RL controllers need weeks of offline training data, SAIR drops a Large Language Model directly into a live, unseen pipeline as an in-context reinforcement learning controller. Learning purely from live experience stored in its context window, SAIR cuts tail latencies by up to 50% and slashes GPU sharing costs by 30–60%—adapting from a cold start in under two minutes.

What Problem Does This Paper Address?

Modern ML inference rarely happens inside a single monolith. Instead, requests flow through an assembly line: CPU-heavy preprocessing (e.g., decoding images), GPU-accelerated neural network execution, and CPU-bound postprocessing, all linked by message queues.

Autoscaling this setup is notoriously tricky due to three coupled headaches:

  1. Dynamic bottleneck migration: As traffic shifts, the choke point jumps between CPUs and GPUs.
  2. Cross-stage coupling: Adding more preprocessing replicas clears the front door, only to trigger a delayed traffic jam at the GPU 30 seconds later.
  3. Confounded causality: High GPU utilization might mean you need more GPUs, or that downstream postprocessing is backed up.

Existing solutions leave engineers in a bind. Production rule-based scalers (like Kubernetes HPA) look at single stages in isolation and end up oscillating wildly. Deep RL controllers understand cross-stage effects, but require thousands of offline training episodes—data you simply don't have when deploying a brand-new pipeline (zero-shot deployment).

Methods

SAIR frames pipeline autoscaling as a contextual bandit operating in 30-second rounds, using an off-the-shelf LLM (GPT-5.1-mini) as an In-Context Reinforcement Learning (ICRL) policy. No gradient updates, no offline simulators. Instead, SAIR learns on the fly by storing (state, action, reward) tuples and feeding the best ones back into the LLM’s prompt.

Figure 1: SAIR architecture. The control plane runs one in-context RL round per decision interval ∆t over the multi-stage pipeline in the data plane; circled numbers mark the steps of a round.

To make an LLM behave like a rigorous control theorist, the authors introduce three clever mechanisms:

  • Pareto-Dominance Reward Shaping: Latency and cost are fundamentally at odds. SAIR tracks an evolving Pareto frontier of optimal latency-cost trade-offs, mathematically guaranteeing a constant reward separation margin between non-dominated ("good trade-off") and dominated actions so the LLM can easily tell them apart amidst noisy telemetry.
  • Bayesian-Surprise Retrieval: Context windows are finite. SAIR stores only positive-reward episodes and retrieves the top-$M$ experiences that are both similar to the current state and high in "Bayesian surprise" (outcomes that deviated sharply from expectations), maximizing information gain.
  • Sub-Millisecond GPU Rate Control: Spinning up new GPU pods takes forever. Alongside standard Kubernetes API calls for CPU/memory, SAIR injects a lightweight user-space LD_PRELOAD layer that intercepts CUDA kernel launches and throttles them via a token bucket. This allows continuous, reversible GPU compute allocation ($\rho \in [0, 1]$) in under 2 milliseconds—freeing up unused GPU cycles for co-located workloads.

Datasets

Because this is a live systems control paper rather than a static modeling benchmark, offline datasets are not used (by design, SAIR starts with an empty buffer). Instead, the authors evaluate SAIR across four live ML serving pipelines (~1M requests per run) with distinct hardware profiles:

  • Image Classification (MobileNetV2; CPU-heavy preprocessing)
  • NLP Analysis (BERT; balanced CPU/GPU with active bottleneck migration)
  • Text Generation (Transformer decoder; GPU-heavy variable latency)
  • Video Analysis (Multi-frame processing; memory-heavy, 10–20s latency)

Each pipeline is stressed under three synthetic arrival patterns: Poisson (steady random traffic), Ramp (gradually climbing load), and Burst (sudden traffic spikes).

Key Insights and Ideas

  • LLMs dodge the "sim-to-real" gap: When the authors faithfully trained classic RL baselines (FIRM and AWARE) in queueing simulators and moved them to real hardware, the frozen policies froze up or failed under bursts. Because SAIR learns strictly online in-context, there is no sim-to-real gap.
  • Curated positivity beats raw history: Filtering out the ~30% of actions that yield negative rewards is crucial. Letting the LLM see all its past mistakes ("Store-All" ablation) actually degraded P99 latency by 12.1% by cluttering the context budget with noise.
  • LLM brains cost pennies compared to GPU brawn: Querying GPT-5.1-mini every 30 seconds costs $0.01–$0.05 per pipeline-hour—orders of magnitude smaller than the cloud compute dollars saved by smarter GPU scaling.
  • Composition over memorization: Under sudden 1.7$\times$ traffic shifts, SAIR produced 4–8$\times$ fewer request timeouts than a nearest-neighbor replay baseline, showing the LLM actively composes novel multi-stage actions rather than just parroting past episodes.

Key Results

  • Tail Latency: SAIR achieves the lowest or tied-lowest P99 latency across all 12 pipeline-workload combinations, cutting P99 by up to 50% over the next-best tuned production baseline.
Figure 2: P99 latency across applications and workload patterns. Lower is better; SAIR (rightmost bar in each subplot) wins or ties on every configuration.
  • Resource Cost: Under GPU sharing/co-location, SAIR reduces effective cost by 30–60% typically (and up to 97% in best-case low-utilization scenarios), validated with physical co-tenants retaining ~98% standalone throughput.
Normalized effective cost across pipelines and workloads, where values above 1 indicate higher cost than SAIR.
  • Fast Cold-Start & Diagnosis: Starting with zero history, SAIR matches a pre-warmed controller's latency within 2–3 decision intervals (47–59 seconds) and identifies injected pipeline bottlenecks with 86% overall accuracy.

Limitations and Future Work

  • Timescale Limits: Because LLM inference takes 1–2 seconds and queues need 5–10 seconds to settle, SAIR targets coarse capacity scaling ($\Delta t \ge 10\text{s}$). Sub-second per-request scheduling (handled by systems like vLLM) is out of scope.
  • When Offline Data Exists: If you do have weeks of historical traces for a static pipeline, dedicated offline-profiled controllers like InferLine remain a better fit.
  • Single-Tenant Savings: The dramatic 97% cost reduction relies on GPU sharing (time-slicing or MIG) where another tenant uses the throttled capacity; in single-tenant whole-GPU billing, savings drop to replica consolidation margins (30–60%).
  • Future Work: The authors highlight disaggregated prefill/decode LLM serving as a natural fit for SAIR's pipeline abstraction, requiring future integration of KV-cache transfer and GPU memory-pressure telemetry.

Summary updated

Abstract

Multi-stage ML inference pipelines are difficult to autoscale because of heterogeneous resources, cross-stage coupling, and dynamic bottleneck migration. Production controllers ignore cross-stage effects, and learning-based autoscalers require offline training data that is unavailable for new pipelines. We present SAIR, an autoscaler for the zero-shot deployment setting that uses an LLM as an in-context reinforcement learning controller, improving its policy online from reward-labeled experience tuples stored in-context. SAIR combines Pareto-dominance reward shaping with a provable separation margin between dominated and non-dominated actions, Bayesian-surprise experience retrieval, and a user-space CUDA interception layer that delivers continuous GPU rate control with sub-millisecond actuation overhead. We prove a regret bound that decomposes into retrieval coverage and LLM selection components, each mapping to a concrete SAIR mechanism. On four ML serving pipelines under three workload patterns, SAIR achieves the best or tied-best P99 latency in every configuration (up to 50% reduction over the next baseline); billable cost is reduced through replica consolidation, and effective cost (which captures GPU rate-control savings under co-location or MIG) by up to 97% under GPU sharing (best case; representative 30-60% over the next-best baseline), validated by co-location measurements on the physical testbed. SAIR matches the steady-state performance of a warm-started controller within 2-3 decision intervals and achieves 86% bottleneck detection accuracy, all from online experience alone.
BibTeX
@inproceedings{su2026sair,
  author = {Jianchang Su and Yifan Zhang and Shengkai Lin and Shizhen Zhao and YUSHENG ZHENG and Yiwei Yang and Wei Zhang},
  title = {{SAIR: Cost-Efficient Multi-Stage ML Pipeline Autoscaling via In-Context Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=8GrzZnygOz},
}
Figure