Phase 05/Operating a distributed serving fleet/Serverless GPU serving and fast cold start
PHASE 05 · Operating a distributed serving fleet

Serverless GPU serving and fast cold start

0%
8 h6 subtopics2 lessons · 2 required
In plain English

A hotel does not keep every shower hot all day; it accepts that the first guest of the morning waits a minute for warm water, and it decides floor by floor which pipes to keep warm based on how full the week looks. Serverless GPU serving is the same trade. Keeping a model loaded on a GPU around the clock is instant but expensive; unloading it when idle is cheap, but the next caller pays a cold-start penalty while the pipes heat up again: find a GPU, start the driver context, read the weights, warm up the kernels. The engineering is deciding what to keep warm, how fast a cold start can possibly be, and how to hide it from the user.

Why it matters

Every major inference provider sells serverless endpoints, and cold start is the make-or-break metric of that product. The same machinery, checkpointing, weight streaming, warm pools, scale-to-zero policies, also decides the economics of any multi-tenant platform, because idle GPUs are the largest avoidable cost in a fleet.

Hiring signal

Baseten asks engineers to work deeply with checkpointing and storage mechanisms to enable sub-10-second startup for trillion-parameter models; Together's platform powers multi-tenant serverless workloads; Modal wants research on autoscaling for spiky serverless traffic; and NVIDIA's NV Cloud Functions team builds an open-source platform that routes inference, streaming, and batch jobs across decentralized GPU clusters.

Skills this topic builds, with the number of the 46 analysed job postings that ask for each. Companies asking: Anthropic, Anyscale, Baseten, Cerebras, Cohere, CoreWeave, Crusoe, Cursor, Databricks, ElevenLabs, Fireworks, Liquid AI, Modal, nvidia, OpenAI, Perplexity, Poolside, Thinking Machines, Together AI, xAI.See all skills →

Learning objectives

  • Decompose a serverless GPU cold start into stages (placement, driver context, weights load, warmup) and measure each.
  • Explain checkpoint/restore and weight-streaming techniques and the limits each faces at trillion-parameter scale.
  • Design warm-pool, keep-alive and scale-down policies and quantify their latency versus GPU-minutes trade-off.
  • Model multi-tenant pooling and fairness, per-tenant SLOs, noisy neighbors and admission control.
  • Turn queue depth and concurrency into autoscaling signals that handle spiky traffic without thrash.

Key concepts

Cold start
The added latency when a request reaches a worker with no model loaded, placement plus CUDA context plus weights plus warmup.
Warm pool and keep-alive
Pre-initialized workers, or a timer delaying unload, that trade idle cost for a lower cold-start rate.
Checkpoint and restore
Saving a fully initialized process image or engine state and restoring it instead of re-initializing from scratch.
Weight streaming
Layered, pipelined loading of weights from local NVMe or remote stores instead of a full download first.
Scale to zero
Removing all workers when idle; cheapest, and the source of the worst cold starts.
Multi-tenant pooling
Serving many models or customers on shared GPUs with per-tenant isolation, fairness and noisy-neighbor control.
Queue-aware autoscaling
Scaling on concurrency and queue depth rather than average utilization, so spikes trigger capacity before SLOs break.

Subtopics

  1. 1. Serverless GPU economics

    Why idle GPUs dominate the bill; utilization versus cold-start rate; what serverless pricing implies about the underlying policy.

  2. 2. Cold-start anatomy

    Placement and scheduling, container start, CUDA context init, weights read, graph capture and warmup; typical seconds per stage and which dominate.

  3. 3. Checkpoint, restore and weight streaming

    Process checkpointing (CRIU), engine-level snapshots, safetensors mmap, layered loading from local cache versus object storage; what breaks at trillion-parameter scale.

  4. 4. Warm-pool and scale-down policy design

    Keep-alive timeouts, predictive warmup by schedule and by traffic shape, per-model hot lists, and the latency versus GPU-minutes curve.

  5. 5. Multi-tenancy and fairness

    Pooling many models and customers, per-tenant SLOs, admission control under scarcity, and defending the 99th percentile from noisy neighbors.

  6. 6. Autoscaling signals for spiky traffic

    Concurrency and queue-depth signals, scale-up lag, cooldown hysteresis, and avoiding oscillation when every new worker itself cold-starts.

Resources

paper
documentation

Hands-on lessons

L1

Measure the anatomy of a GPU cold start

Colab T4 · freeexperiment120 minrequired

Goal · A measured budget of a cold start on a free T4 for a 1-3B parameter model, split into CUDA context init, weights load, and first-token warmup, plus one optimization applied and re-measured.

  1. 1Time a cold CUDA context init (first CUDA op in a fresh process) separately from torch import time.
  2. 2Time loading a 1-3B model from local disk with safetensors versus a simulated object-storage download (copy over a throttled loopback or timed file copy).
  3. 3Time first-token latency for the first request after load versus the second request, isolating warmup (kernel autotune, allocator growth).
  4. 4Apply one optimization, safetensors mmap, warm CUDA context reuse, or pre-captured graphs, and re-measure each affected stage.
  5. 5Tabulate the budget and state which stage dominates and what the next optimization would be.
Deliverable
A notebook with the per-stage timing table, before and after the optimization, and one plot of first versus second request latency.
Check
The three stages are measured separately with at least 5 repetitions each; the optimization shows a measurable improvement in at least one stage with the number reported.
Fallback
Do the exercise with a 125M model on CPU, timing process start, weights load and first forward pass; the stage anatomy and method are the lesson, the absolute numbers differ.
L2

Simulate a serverless gateway and price its policies

CPU · your Macscript120 minrequired

Goal · A discrete-event simulator of a serverless GPU gateway (cold and warm pool, keep-alive timeout, bursty arrivals) that reports cold-start rate, latency percentiles and GPU-minutes per policy.

  1. 1Implement workers with cold and warm states, cold-start time drawn from your l1 measurements, warm service time from a decode benchmark.
  2. 2Generate a bursty arrival process (Poisson clusters with a peak-to-mean ratio of 5) over a simulated day.
  3. 3Add a keep-alive timeout policy, worker goes cold after T idle seconds, and sweep T from 0 (scale to zero immediately) to 3600.
  4. 4Record cold-start rate, p50 and p99 added latency, and GPU-minutes consumed per policy.
  5. 5Add a simple queue-aware autoscaler that grows the pool when queue depth exceeds a threshold with a scale-up lag, and re-run the sweep.
  6. 6Plot the latency versus GPU-minutes frontier and pick a policy for a stated SLO, defending the choice in three sentences.
Deliverable
gateway_sim.py, the policy sweep table, the frontier plot, and the three-sentence policy recommendation.
Check
Cold-start rate falls and GPU-minutes rise monotonically as T grows; at least one policy meets p99 added latency under 2 s within 25 percent of the cheapest policy's GPU-minutes, or the report explains why none can.

Build your own

Build your own serverless inference gateway

PythonCPU · your Mac~4 h

A discrete-event gateway with cold and warm pools, keep-alive policy, queue-aware autoscaling, and a priced latency frontier.

The real thing: github.com/ServerlessLLM/ServerlessLLM ↗

How you know a stage passes

You write tests/gateway.spec.py first. Deterministic seeds make the simulation reproducible; the tests assert queueing invariants (no request served before arrival, cold workers never serve instantly), monotonicity of the policy sweep, and reproducibility of two runs with the same seed.

Stages, in order. Each one leaves you with something that runs.0/5
  1. 01one worker with cold and warm states
    A single worker serves a request stream with cold-start and warm service times, logging cold starts.
    test · pytest asserts a request after an idle gap pays the cold-start time and a back-to-back request does not.
  2. 02a pool with a FIFO queue
    N workers with a shared FIFO queue; latency percentiles are reported.
    test · pytest asserts no request starts before its arrival time and p99 is computed correctly on a known trace.
  3. 03keep-alive timeout policy
    Workers go cold after T idle seconds; the sweep over T records cold-start rate and GPU-minutes.
    test · pytest asserts cold-start rate is non-increasing and GPU-minutes non-decreasing as T grows.
  4. 04queue-aware autoscaling with lag
    The pool grows when queue depth crosses a threshold, new workers arriving after a scale-up lag and cold start.
    test · pytest asserts an autoscaled run has strictly lower p99 than the fixed-pool run on the same burst trace, at higher GPU-minutes.
  5. 05the priced frontier and policy memo
    A latency versus GPU-minutes frontier across policies and a short memo recommending one for a stated SLO.
    test · pytest asserts the frontier contains at least five distinct policies; the memo names the SLO, the chosen policy, and its cost premium.

Knowledge check

QName the four stages of a serverless GPU cold start and the one that usually dominates.

Placement or scheduling, CUDA context init, weights load, and warmup; weights load usually dominates for large models, which is why checkpointing and weight streaming exist.

QWhy is scale-to-zero the cheapest and the slowest policy at the same time?

It frees every idle GPU (no idle cost) but guarantees every returning request pays a full cold start.

QWhat does a keep-alive timeout actually trade, and how would you set it with data?

Idle GPU-minutes against cold-start rate; set it by simulating or measuring the arrival process and picking the cheapest T whose cold-start rate meets the latency SLO.

QWhy scale on queue depth rather than average GPU utilization for spiky traffic?

Utilization is a lagging average that looks fine while a spike queues; queue depth reacts within seconds, so capacity is requested before SLOs break.

QGive one reason checkpoint or restore beats re-initialization and one limit of it at trillion-parameter scale.

It skips context init and warmup and starts from a ready image; the limit is that the image itself is enormous, so restore time becomes a storage-bandwidth problem again.

Completion

  • All 6 subtopics marked done
  • All 2 required lessons done
  • All subtopics marked completed.
  • Lessons l1 and l2 deliverables saved and checks pass.
  • Can whiteboard the cold-start budget of a 70B model and defend a keep-alive policy with numbers.
Topic progress is derived; it reaches 100% when both checks above pass.Next recommended topic →