Skip to departures
Hpjadul
MAC END

Optimizing Serverless GPU Inference: Achieving Rapid Scaling and High Utilization

Departs
Crew
Charles Frye
Passengers
700

Modal’s approach to serverless GPUs enhances allocation utilization and minimizes start times, addressing the challenges of dynamic inference workloads.

Optimizing Serverless GPU Inference: Achieving Rapid Scaling and High Utilization

In today's AI landscape, large-scale inference is paramount, with billion- to trillion-parameter neural networks leveraging specialized accelerators to perform quadrillions of operations each second. In such an environment, efficiency and rapid response time are crucial, particularly with the advent of serverless computing, which offers flexibility in managing variable workloads.

Diagram indicating latency to scale up an inference server in a baseline cloud system and on Modal

However, the challenge lies in quickly provisioning the necessary server infrastructure to meet fluctuating demands. Without significant optimizations, launching a new instance of a model like SGLang can take tens of minutes or more, severely impacting response times. Through five years of dedicated engineering, Modal has addressed these latency issues and enabled what they term "truly serverless GPU" operations. This article outlines the strategies employed and the significant improvements achieved.

Diagram of simulated inference traffic from a time-varying Poisson process with seasonal variation and spikes

The Four Pillars of Serverless GPU Infrastructure

Modal has identified four key components that collectively enhance the performance and scalability of GPU inference:

Diagram indicating latency to scale up an inference server in a baseline cloud system and on Modal
  • Cloud Buffers: This approach maintains a small backlog of healthy, idle GPUs, enabling them to take on new workloads almost immediately.
  • Custom Filesystem: This is designed to load container images lazily from a multi-tier, content-addressed cache, thus reducing the time required to set up containers.
  • Checkpoint/Restore: By enabling rapid CPU-side initialization through direct restoration of processes into memory, this technique minimizes startup durations.
  • CUDA Checkpoint/Restore: This innovation applies similar principles to GPU-side initialization, allowing for the quick restoration of GPU contexts.

Together, these techniques have reduced the time needed to scale AI inference server replicas from several kiloseconds to mere tens of seconds, ensuring a more responsive and economically viable system.

Diagram indicating latency reduction of tens of minutes for inference startup with a cloud instance buffer.

The Importance of Maximizing GPU Allocation Utilization

To understand the significance of serverless GPUs, it is imperative to discuss GPU allocation utilization—a metric that reflects how effectively the GPU resources are being used relative to their cost.

A mathematical optimization formulation for selecting GPU instance launches. Parameters define total requested GPUs, buffer GPUs, possible instance types, costs, and scaling limits. The output is a vector of instances to launch by type. The objective minimizes total cost, subject to providing at least the requested plus buffer GPUs, assuming 8 GPUs per instance, and keeping each instance count within its type-specific scaling limit.

Defining GPU Allocation Utilization

GPU Allocation Utilization is defined as:

Diagram of the solver service

GPU Allocation Utilization := GPU-seconds running application code ÷ GPU-seconds paid for

This metric contrasts with Model FLOP/s utilization, typically emphasized during training phase evaluations. For inference, the more relevant metric focuses on how consistently GPUs can be deployed without being left idle.

Diagram showing lazy loading of container filesystem contents concurrently with spinup

The demand for inference capacity often experiences unpredictable fluctuations due to external factors. These variations can lead to a high peak-to-average ratio, complicating cost management. For example, resources allocated on a traditional fixed basis may lead to idle GPU time, with utilization rates as low as 10-20% under peak conditions.

The Latency Challenge in Provisioning Serverless GPUs

The natural solution to the disparity between variable demand and resource allocation is auto-scaling; however, naive implementations can exacerbate latency issues, ultimately degrading service quality when demand surges ahead of server provisioning.

Diagram showing lazy loading of container filesystem contents concurrently with spinup

Existing processes can introduce delays during:

Diagram depicting multiple container filesystems with overlapping content stored in a content-addressed cache
  • Instance spin-up and health-checking: Can take anywhere from minutes to tens of minutes.
  • Filesystem state loading: Often requires additional seconds to load application dependencies.
  • Application initiation on hosts and devices: Can stretch from tens of seconds to several minutes.

Under typical conditions, the inability to scale capacity quickly results in degraded user experience, characterized by longer queuing times and potentially critical 503 errors when demand exceeds provisioned resources.

Diagram indicating latency reduction of 33% for inference startup with the custom container filesystem.

Buffering and Rapid Provisioning Strategies

To address latency in GPU provisioning, Modal has implemented a cloud buffer strategy that allows them to retain a group of idle GPUs ready for immediate use. This allows for rapid service provisioning, as requests can be immediately directed to these pre-allocated resources, effectively removing up to tens of minutes from the instance spin-up time.

Diagram showing requested blocks and read blocks with different levels of readahead.

Furthermore, decomposing and managing this buffer allows Modal to optimize their allocations, ensuring resources are utilized efficiently. By leveraging linear programming techniques, the system can intelligently balance the active instances against the buffer to minimize costs while meeting the demand efficiently.

Diagram showing the internals of a Linux process as a data structure - memory mappings, thread state, file descriptor table.

Transforming Container Startup with Lazy Loading

Loading application images from traditional sources can be a time-consuming bottleneck that impedes the speed of container deployment. To overcome this, Modal has introduced a custom filesystem called ImageFS that disaggregates container launching from image delivery.

Diagram demonstrating the 'skipped work' when restoring a process from a checkpoint.

By implementing a lazy loading mechanism coupled with a content-addressed cache, containers can now begin operational readiness in as little as 100 milliseconds, with the bulk of the filesystem loaded concurrently or deferred as necessary. This technique is bolstered by a tiered cache system that prioritizes latency-effective access to frequently utilized files, reducing typical startup times significantly.

Diagram of the gVisor checkpoint/restore process, including nvproxy.

Improving Start Times with Checkpoint and Restore Technologies

The checkpointing methodology applied to CPU processes is instrumental in reducing the setup time of new replicas. When a running process state can be preserved and restored, it allows for instant access to memory configurations and environmental settings, significantly cutting down the operational overhead associated with initializing new workloads.

Diagram indicating a reduction in start latency from 300s to 50s for inference applications with snapshots.

This process generates a compressed image of the application state, which can be restored in a fraction of the time it would typically take to build from scratch, resulting in approximately 10-fold reductions in time for the application host-side processes.

Device Memory Snapshotting

Extending this principle to GPU resources means employing NVIDIA's latest checkpointing capabilities, which capture GPU memory states alongside the host application's state. This dual-layer checkpointing allows both the host and GPU associated processes to be initialized more rapidly, ultimately trimming inference server replication time significantly from minutes down to a few tens of seconds.

Real-World Application and Impact

Implementing these advancements has allowed Modal to handle tens of millions of replicas across various applications effectively. From February to April 2026 alone, almost 35 million CPU snapshots and over 15 million GPU snapshots were executed to serve distinct organizations, illustrating the efficacy and scalability of the system.

Particularly notable use cases include platforms like Reducto, which successfully process document structure extraction using large language models. By making cold starts effectively instantaneous, Reducto can meet urgent customer demands without needing to maintain excess capacity, operationalizing an efficient serverless GPU approach for demanding workloads.

The Future of Serverless GPUs

The advancements outlined here fundamentally alter how GPU resources can be accessed and utilized, especially for inference workloads. By overcoming traditional barriers posed by latency and underutilization, Modal's serverless GPU infrastructure is designed for the demanding requirements of AI applications.

As this technology continues to evolve, the potential for improved application performance, cost-effectiveness, and user satisfaction will keep advancing, making serverless GPUs an area of significant interest for developers and organizations focused on AI infrastructure.

To further engage with the developments at Modal or explore opportunities to contribute to this rapidly growing field, interested individuals can still participate in shaping the future of computation through inquiries on Modal's career page.

Source: Charles Frye · modal.com
Arrived · Hpjadul

Also departing from this gate