KAIROS: Building Cost-Efficient Machine Learning Inference Systems with Heterogeneous Cloud Resources

Baolin Li, Siddharth Samsi, Vijay Gadepally, Devesh TiwariarXiv 2022 · DOI

TL;DR

KAIROS is a novel runtime framework designed to maximize machine learning inference throughput on heterogeneous cloud resources while strictly adhering to cost budgets and latency targets (QoS). By replacing expensive online trial-and-error with a mathematical throughput estimation method and an intelligent query-to-hardware mapping system, KAIROS achieves up to 2× the throughput of traditional homogeneous clusters and outperforms state-of-the-art methods by up to 70%.

What Problem Does This Paper Address?

Deploying machine learning (ML) models for online inference is a balancing act. Businesses want high throughput (processing as many requests as possible) but are constrained by two factors: Quality-of-Service (QoS), usually defined as a tail-latency deadline (e.g., 99% of queries must finish within 100ms), and a fixed cost budget.

Cloud providers offer a dizzying array of Virtual Machines (VMs) with different CPUs, GPUs, and memory configurations. While a heterogeneous mix of these resources (e.g., combining a few powerful GPUs with several cheaper CPUs) theoretically offers a better cost-performance trade-off, finding the "perfect mix" is incredibly difficult. The search space is massive, and testing a single configuration online takes tens of seconds, during which the system might fail to meet its QoS targets. Consequently, most practitioners stick to homogeneous clusters, leaving significant performance and cost-savings on the table.

Methods

KAIROS tackles this challenge through two primary innovations:

  1. Intelligent Query Distribution (The "How to Map"): Not all inference queries are equal; they arrive in varying batch sizes. KAIROS treats the problem of assigning queries to specific hardware instances as a min-cost bipartite matching problem. It introduces a "heterogeneity coefficient" to normalize the "value" of a second of compute time across different hardware types (e.g., one second on a GPU is "worth" more than one second on a CPU). By prioritizing queries that get the biggest speedup on more powerful instances, KAIROS creates more "slack time" to handle future queries.

    Figure 5: Higher-speedup queries should be prioritized on more powerful instances to create more slack time. Queries 1 to 4 (arrived in order) are represented in different colors.
  2. Throughput Estimation (The "How to Mix"): To avoid the "exploration overhead" of testing different VM combinations online, KAIROS uses a mathematical model to estimate a throughput upper bound for any given configuration. It analyzes the distribution of incoming query sizes and calculates which hardware type would become the bottleneck. This allows KAIROS to rank thousands of potential configurations in seconds and pick a winner without ever deploying a sub-optimal cluster.

The authors also developed KAIROS+, a version that uses a tiny amount of online evaluation (less than 1% of the search space) to further refine the selection.

Datasets

The researchers evaluated KAIROS using industry-grade ML models and real-world traffic patterns:

  • Models: Five diverse models including Neural Collaborative Filtering (NCF), Meta’s recommendation model (RM2), Google’s Wide and Deep (WND), Multi-Task Wide and Deep (MT-WND), and Alibaba’s DIEN.
  • Traces: Evaluation was driven by production traces of real query batches from Meta, using both Poisson and Gaussian distributions to simulate realistic arrival patterns.
  • Hardware: A pool of AWS EC2 instances including g4dn.xlarge (GPU), c5n.2xlarge (Compute-optimized CPU), r5n.large (Memory-optimized CPU), and t3.xlarge (General-purpose CPU).

Key Insights and Ideas

  • Heterogeneity is a Double-Edged Sword: Simply adding different types of hardware doesn't guarantee success. As shown in Figure 1, some heterogeneous mixes perform significantly worse than a cost-equivalent homogeneous setup.

    Figure 1: Different heterogeneous configurations versus the best homogeneous one. The number indicates the instance count of each type.
  • Slack Time is Throughput: The secret to high throughput isn't just processing the current query fast; it's processing it on the instance that leaves the most collective "free time" across the whole cluster for the next set of queries.

  • Predictability is an Asset: Because ML inference is largely deterministic (latency is highly correlated with batch size), we can model system behavior mathematically rather than relying on black-box optimization or exhaustive testing.

Key Results

  • Throughput Gains: KAIROS achieved up to 2× the throughput of the best possible homogeneous configuration for the RM2 model and at least 1.25× for all other models.
  • Outperforming SOTA: Compared to existing schemes like Ribbon, DeepRecSys, and Clockwork, KAIROS improved throughput by up to 70%.
  • Zero-Shot Configuration: KAIROS successfully identified near-optimal configurations without any online exploration, whereas competing methods often required evaluating 5-30% of the search space to reach similar performance.
  • Robustness: The system remained effective even when the researchers intentionally injected 5% latency noise or suddenly changed the query size distribution (e.g., shifting from Log-normal to Gaussian traffic).

Limitations and Future Work

While KAIROS is highly effective, the authors note a few areas for further exploration:

  • Latency Predictability: The framework assumes inference latency is highly predictable. While true for most ML workloads, extreme resource contention or "noisy neighbors" in a public cloud could introduce variance that might require more sophisticated noise-handling.
  • Scaling: For extremely large systems, the authors suggest a "divide and conquer" approach—splitting the cluster into sub-systems each managed by a KAIROS instance—to ensure the central controller doesn't become a bottleneck.
  • Broader Applicability: The two-pronged approach (upper-bound estimation + bipartite matching) could potentially be applied to other systems optimization problems beyond ML inference.

Summary updated

BibTeX
@misc{li2022kairos,
  author = {Baolin Li and Siddharth Samsi and Vijay Gadepally and Devesh Tiwari},
  title = {{KAIROS: Building Cost-Efficient Machine Learning Inference Systems with Heterogeneous Cloud Resources}},
  year = {2022},
  eprint = {2210.05889},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.05889},
}
Figure