---
title: "26-Minute to 7-Second Cold Start: GPU Memory Snapshots at Scale | Yuvraj Garg"
seo_title: "26m to 7s GPU Cold Starts: Memory Snapshots & Scale-to-Zero | Yuvraj Garg"
slug: "cold-start-engineering"
canonical_url: "https://www.yuvraj97.com/deep-dives/cold-start-engineering"
raw_markdown_url: "https://www.yuvraj97.com/deep-dives/cold-start-engineering.md"
author: "Yuvraj Garg"
author_title: "AI Systems & Infrastructure Architect"
author_linkedin: "https://www.linkedin.com/in/yuvraj97"
article_section: "Performance Optimization"
date_published: "2025-02-10"
date_modified: "2025-02-28"
reading_time_minutes: 5
target_audience: ["AI Agents", "Cloud Architects", "MLOps Teams"]
keywords:
  - "cold start optimization"
  - "GPU memory snapshots"
  - "CRIU checkpoint"
  - "vLLM cold start"
  - "scale-to-zero"
  - "Modal GPU"
  - "llama.cpp cold start"
  - "SGLang memory saver"
metrics: "26m -> 7s (222x faster cold start)"
---

# 26-Minute to 7-Second Cold Start: GPU Memory Snapshots at Scale

> 26-minute to 7-second cold start: GPU memory snapshots, FlashInfer JIT caching, volume symlinks, scale-to-zero on Modal B200 clusters.

- **Human Web View:** [https://www.yuvraj97.com/deep-dives/cold-start-engineering](https://www.yuvraj97.com/deep-dives/cold-start-engineering)
- **Raw Markdown URI:** [https://www.yuvraj97.com/deep-dives/cold-start-engineering.md](https://www.yuvraj97.com/deep-dives/cold-start-engineering.md)

---

## TL;DR & Core Architectural Milestones
- **Highest-Leverage Optimization:** GPU memory snapshots are the most impactful optimization, delivering 5× to 24× cold start reductions across diffusers, llama.cpp, and SGLang.
- **In-process Loading Mandatory:** Capturing full GPU state with CRIU requires in-process model loading; child processes (e.g. `subprocess.Popen`) are invisible to the snapshot system.
- **SGLang & llama-server Configurations:** SGLang requires `--enable-memory-saver` to offload KV cache to CPU during capture. Llama-server requires `--no-mmap` for checkpointing compatibility.
- **Warmup Requests:** Running warmup queries before snapshotting forces CUDA JIT kernel compilation, keeping it out of the cold start path.

---

## 1. Empirical Cold Start Reductions Across Engines

GPU memory snapshots capture the complete host RAM and CUDA VRAM state at a specific checkpoint, restoring running processes from NVMe storage in seconds rather than reloading weights and compiling JIT graphs from scratch.

| Model Checkpoint | Inference Engine | Before (Cold) | After (Snapshot Restore) | Speedup Factor |
| :--- | :--- | :---: | :---: | :---: |
| **FLUX.2-klein-9B** | diffusers (PyTorch) | 48s | **~7s** | **6.9×** |
| **GLM-4.7-Flash GGUF** | llama-cpp-python | 110–168s | **2–7s** | **24.0×** |
| **Gemma 4 26B GGUF** | llama-server | 60–120s | **5–15s** | **5–10×** |
| **Qwen3.5-35B-A3B FP8** | SGLang | 2–5 min | **12–20s** | **~10.0×** |

---

## 2. What Dominates Cold Start Time Before Snapshots?

Without memory snapshots, container startup time breaks down into four sequential latency sinks:

1. **Weight Download & Disk I/O (40–60% of time):** Pulling 10–50 GB of model safetensors from cloud object storage over network interfaces takes 30 to 180 seconds.
2. **CUDA Context & Driver Initialization (15–25%):** Allocating multi-gigabyte CUDA memory pools, initializing cuBLAS and cuDNN contexts takes 5 to 15 seconds.
3. **Weight Deserialization & Host-to-Device Copy (15–20%):** Loading tensors from RAM into GPU VRAM over PCIe or NVLink.
4. **JIT Kernel Compilation & Warmup (10–25%):** Compiling FlashAttention, Triton, or FlashInfer kernels on the first inference pass.

Memory snapshots bypass all four phases simultaneously by serializing the initialized process directly.

---

## 3. Critical Engine-Specific Hardening Rules

### Rule 1: In-Process Loading Is Mandatory
Linux CRIU checkpoints snapshot the memory space of the main container process. Spawning inference engines via `subprocess.Popen("vllm serve ...")` renders the engine invisible to the snapshotter. All model loading must occur in-process (e.g. `LLMEngine.from_engine_args(...)` or direct Python class instantiation).

### Rule 2: SGLang Memory Saver
SGLang pre-allocates up to 90% of GPU VRAM for its KV cache on boot. Capturing this massive empty buffer bloats snapshot images beyond 20 GB. Passing `--enable-memory-saver` instructs SGLang to release dynamic buffers prior to checkpoint capture.

### Rule 3: Llama-server `--no-mmap`
`mmap` memory mappings cannot be cleanly checkpointed across distinct container instances. Passing `--no-mmap` forces contiguous virtual memory allocations compatible with CRIU.

---

## 4. Frequently Answered Architecture Questions (FAQ)

### Q: How much can GPU memory snapshots improve cold start times?
Across four engines and models, snapshots deliver 5× to 24× cold start reductions: from 48s to ~7s on FLUX.2, and from 110s to 2–7s on GLM-4.7-Flash GGUF.

### Q: Why is in-process model loading mandatory for snapshots?
CRIU captures the memory hierarchy of the root Python container process. If an engine is spawned via an external subprocess, its CUDA memory allocations and state are not captured in the snapshot image.

### Q: How should JIT kernels be handled before snapshotting?
Always execute a dummy warmup query (e.g. 1 short inference pass) inside the snapshot creation hook. This forces PyTorch and Triton to compile their dynamic execution graphs before the memory state is frozen.
