Loading model weights from S3 into a pod
A cold start took about 155 s whichever way I loaded the model. A warm restart took 6 s, 60–71 s or 81 s depending on the method.
4 min read
- Kubernetes
- Amazon S3
- LLM inference
- Startup time
A model's weights are large files that every serving pod needs before it can answer anything. How they get from storage into the pod decides how long a restart, a rollout or a scale-out takes. I compared three ways of doing it for my local LLM platform. Here is what I measured and what I took from it.
Why not put the model in the container image
The model is Qwen3-4B, quantized to Q4_K_M and Q4_0. Baking multi-gigabyte weights into the container image makes every image pull heavy, and it ties a model change to an image rebuild. So the model lives in S3, and pods fetch it when they start.
That moves the problem rather than removing it. Pod startup time was the thing I needed to fix, and the answer depended on how the fetching worked.
How the model is stored
The model is split into shards of 512 MB and 1 GB, with a SHA-256 manifest. The manifest records a SHA-256 for each shard, so a download can be verified. Small shards also make a failed transfer cheaper to retry, because only the broken piece is fetched again, though I did not measure that.
Three ways to load it
I compared three loading methods on startup time:
- Node cache. Shards stay on the node's disk, so a restarted pod finds them already there.
- Mountpoint for Amazon S3. The bucket is mounted as a filesystem and the model is read through it.
- Init-container prefetch. An init container downloads the shards before the main container starts.
What I measured
The first cold start took about 155 s with every method. A warm restart, when the node had already served the model, was where they differed:
| Method | Warm restart |
|---|---|
| Node cache | 6 s |
| Mountpoint for S3 | 60–71 s |
| Init-container prefetch | 81 s |
Reading the numbers
The loading method did not matter for the first cold start, since all three came out at about 155 s. These numbers do not break that 155 s down, so I will not claim where it goes. It matters only that the method was not what decided it.
Warm restarts are different. The node cache is the one method that keeps the data on the node, and it is the one that restarts in 6 s. The other two go back to S3 on a restart, one by reading through the mount and the other by downloading again before the container starts. That fits their 60–81 s results, though I did not instrument the reads to confirm it.
The default is the node cache with 1 GB shards.
Why startup time matters here
This platform scales with KEDA and adds nodes with Karpenter. Every new replica has to load the model before it can help, and every rollout restarts pods that already had it. A 6 s warm restart makes rollouts and crash recovery cheap. An 81 s one makes them something to plan around.
A side result: the quantization choice
While measuring the platform I also compared the two quantizations. Q4_0 generated at 3.9 tokens per second against 3.0 for Q4_K_M, about 30% faster. I have not measured answer quality or memory saved, so I do not yet know what that speed costs. It is a reminder to check quality before treating the faster option as the better one.
The trade-off
A node cache makes restarts fast but does nothing for a brand-new node, which still pays the full cold start. Karpenter adds nodes as demand grows, so those new nodes are exactly where the cost lands.
If you run a comparison like this
A few habits that would keep it honest, from how I would structure it:
- Define cold and warm before you start, and measure both for every method.
- Time from when the pod is created to when it is ready to serve, not just the download.
- Keep shard size the same across methods, or vary it deliberately and record it.
- Repeat each measurement, because a single run can mislead.
What I would test next
If new-node startup mattered more, warming the cache ahead of time is what I would try. Pre-populating the cache before traffic reaches a new node would turn some of the cold start into something that happens off the critical path.