Abstract
Serverless computing has become increasingly popular for machine learning inference. However, current serverless platforms lack efficient support for GPUs, limiting their ability to deliver low-latency inference. In this paper, we propose FaaSwap, a GPU-efficient serverless inference platform. FaaSwap employs a holistic approach to system and algorithm design. It maintains models in main memory and dynamically swaps them onto GPUs upon request arrivals (i.e., late binding), thereby enabling a large number of inference functions to efficiently share a node's GPUs. FaaSwap uses various techniques, including asynchronous API redirection, GPU runtime sharing, pipelined model execution, and efficient GPU memory management, to achieve the optimal performance. We also develop an interference-aware request scheduling algorithm that allows FaaSwap to meet the latency SLOs for individual inference functions. We have implemented FaaSwap as a prototype on a leading commercial serverless platform. Experimental evaluations demonstrate that, with model swapping, FaaSwap can concurrently serve hundreds of functions on a single worker node with 4 V100 GPUs, while achieving inference performance comparable to native execution.
Introduction: The GPU Efficiency Gap
While serverless computing is highly effective for CPU-based tasks, it faces significant challenges when integrated with GPUs. Current platforms typically employ "early binding," where a model is loaded into a GPU's dedicated memory (VRAM) and remains there as long as the service is active. This approach leads to a massive efficiency gap: production data indicates that 85% of inference functions are invoked less than once per minute. Keeping these models idle in expensive GPU memory wastes resources for providers and increases costs for users. Conversely, loading a model from scratch (a "cold start") can take tens of seconds, which is unacceptable for real-time applications. FaaSwap addresses this by sharing a limited pool of GPUs among hundreds of infrequent functions without sacrificing latency.
System Design: Late Binding and Model Swapping
FaaSwap manages GPUs as a shared resource pool through several key innovations centered around a "late binding" approach. Models are stored in the larger and more cost-effective host RAM and are dynamically "swapped" onto an available GPU only when a request arrives.
The architecture relies on several technical pillars:
- Asynchronous API Redirection: To minimize communication overhead between the function and the GPU, FaaSwap redirects CUDA calls asynchronously, synchronizing only when necessary for final output.
- Pipelined Execution: The system overlaps the transfer of model layers with the computation of layers already present on the GPU, reducing total latency.
- Interference-Aware Scheduling: Models are categorized by swap overhead. FaaSwap utilizes high-speed NVLink connections for "heavy" models to avoid PCIe bottlenecks and schedules requests to minimize resource contention.
- SLO-Aware Queuing: Using a "Required Request Count" (RRC) metric, FaaSwap prioritizes requests at higher risk of missing their Service Level Objective (SLO) deadlines.
- Custom Memory Management: A custom shim layer with a Buddy allocation scheme manages a pre-reserved GPU memory pool, avoiding the latency of native
cudaMalloccalls and preventing fragmentation.
Evaluation and Performance
FaaSwap was evaluated using production traces from Alibaba Cloud and a suite of standard benchmarks, including ResNet-152, Bert-qa, Stable Diffusion, and large language models like Llama3-8B and Qwen-14B.
Key results include:
- Cost Efficiency: In pilot deployments, FaaSwap reduced GPU provisioning costs by 70% for users and 65% for the platform.
- High Density: A single worker node with 4 GPUs served 480 concurrent inference functions while maintaining millisecond-scale SLOs.
- Latency Reduction: FaaSwap significantly outperforms cold starts. For Llama2-13B, startup time was reduced from 61 seconds to just 4.4 seconds (combining model swap and runtime overhead).
- Throughput: At low request rates, FaaSwap achieved over 10x higher throughput than traditional early-binding methods by packing more functions onto the same hardware.
Conclusion and Future Work
FaaSwap demonstrates that host RAM can serve as an effective "waiting room" for idle models, freeing VRAM for active computation. By working at the CUDA API and memory block level, FaaSwap remains model-agnostic and "plug-and-play" for proprietary architectures.
Future work will address extremely infrequent functions through multi-tier storage (e.g., SSD/Disk) and extend the swapping mechanism to support model-parallel execution for models exceeding the capacity of a single GPU. Additionally, proactive caching strategies are being investigated to handle extreme workload bursts.
Summary updated