Introduction
Memory checkpointing — sometimes called memory snapshotting — takes a snapshot of a container’s GPU and CPU memory and uses that to speed up the startup of all future containers. The snapshot acts like a preloaded copy of your model and runtime state, so new containers restore from the snapshot instead of cold-starting from scratch. Applications that perform a large amount of work at container start time benefit the most from this process. For example, Machine Learning and LLM frameworks load massive model weights and compile various CUDA kernels at container start time, taking many minutes. Loading a checkpoint that already contains the compiled CUDA kernels can skip this delay entirely. Cerebrium has native checkpointing and restore functionality built in to the platform.How To Use
Checkpointing is available on our v2 runtime environment. Add the following to yourcerebrium.toml to upgrade.
- A checkpoint already exists for the current build version.
- Another container instance is already undergoing the checkpointing process.
CEREBRIUM_RESTORED: container restored from checkpoint as the first log line in the container.
A checkpoint is tightly coupled to a single deployment. To disable restoring from checkpoints simply remove the POST request and redeploy your application.
Example
Limitations
Memory Overhead: The container memory allocation needs to be large enough to contain the GPU memory dump in addition to your regular memory use. Execution Lifecycle: When a container is restored from a checkpoint execution continues from the point where the http request is sent. If environment variables were read before this point they will remain the same as they were from the time of the checkpoint. Network Connections: Any TCP connections that were made before the checkpoint will have disconnected. For example if you connected to a database before the checkpoint you will have to reestablish that connection after restore. Ephemeral Filesystem: Any files written to disk before the checkpoint will not be copied to the restored container. Only memory is checkpointed. Provider Availablity: Checkpointing is only available on the AWS provider. More coming soon.Platform specific recommendations
vLLM
vLLM checkpointing support is not complete but still possible. See https://github.com/vllm-project/vllm/issues/34303 and other issues. If you are getting an EngineCoreDead exception addasync_scheduling=False to your AsyncEngineArgs and it should succeed.
The larger the size of the memory checkpoint the slower the restore is. We can reduce the size of the snapshot substantially and improve startup times by dropping the KV Cache before checkpoint and recreating it after restore. vLLM has functionality that does this built in as part of vLLM Sleep Mode.
You