Introduction
Memory checkpointing takes a snapshot of a container’s CPU memory and GPU memory, and uses it to speed up the startup of future containers. Applications that perform a large amount of work at container start time benefit the most from this process. This is useful for both CPU-only and GPU workloads. For CPU applications, checkpointing can preserve expensive initialization work such as imports, dependency loading, configuration setup, and in-memory state. For GPU applications, it can also preserve model weights, CUDA state, and compiled kernels. For example, ML and LLM frameworks often load large model weights and compile CUDA kernels at container start time, which can take many seconds or minutes. Loading from a checkpoint that already contains this initialized state can skip most of that delay. Since this feature is still in beta, please report all issues to the team via our Discord Community or via Email.How To Use
Checkpointing is available in early beta to our customer base. Add the following to yourcerebrium.toml in order to use it.
- 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.
You can find several implementations in our Examples repository on Github.
vLLM 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 Availability: 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.