Tech Blog
Model swapping on the fly with zero downtime
How we move production from one gemma-4-31B version to the next with no spare GPU, why the stock rollout and the usual GPU schedulers do not cover it, and what each swap cost in time and latency.
By Ariff Nazhan
Senior AI Infrastructure Engineer
In this post, Ariff Nazhan, our Senior AI Infrastructure Engineer, explains how the team replaces the AI model behind our text and voice agents without taking them offline and without buying spare GPUs. Each retrained model can go in front of customers when it is ready, and a GPU server can be freed for training without an outage. In production, moving the live model to a new GPU layout answered 2,339 of 2,340 test requests (the one failure came from a proxy outside our cluster), and an update that changes only the model's weights now pauses answers for 3 to 17 seconds instead of the 8 to 10 minutes a restart takes.
We serve a fine-tuned gemma-4-31B for our text and voice agents with NVIDIA Dynamo and vLLM, split into a disaggregated pair. A prefill engine processes the prompt, a decode engine generates the tokens, and the KV cache (the attention keys and values the model computed for the prompt) moves between them over NIXL, NVIDIA's transfer library. Our earlier post, Heterogeneous TP on gemma-4, explains how the two engines split the work and why they can run on different numbers of GPUs. The cluster is two nodes of eight B300 GPUs on k3s, a lightweight Kubernetes, with HAMi capping how much GPU memory each container can use. Each card has 275 GB, of which vLLM sees 267.69 GiB.
We retrain often, so the model behind the API changes often. A cold engine takes 8 to 10 minutes to load, and there is no spare node to stand a second copy on. This post covers how we swap the pair anyway, and what happened when we ran it in the lab and in production on 21 November 2026.
Why the stock rollout does not fit
Editing the model in a DynamoGraphDeployment makes Dynamo's operator roll each component with maxSurge: start the new pod, wait for it to be Ready, delete the old one. That works when there are spare GPUs. On ours it breaks in three places:
- No room for a surge. Our engines run at
--gpu-memory-utilization 0.70. A second engine at 0.70 does not fit beside the first. - Prefill and decode roll separately. A request prefilled by the new model must be decoded by the new model. The KV cache computed by one version's weights means nothing to another's, yet rolled one component at a time, a new prefill can hand off to an old decode.
- Ready is not routed. A pod that passes its readiness probe is not necessarily receiving traffic from the frontend, Dynamo's request router. Delete the old engine at that moment and requests have nowhere to go.
The usual GPU tools each answer a different question, so none of them sequences this swap:
| Tool | What it decides | Why it does not swap our pair |
|---|---|---|
| Dynamo operator | Rolls each component with maxSurge and maxUnavailable | No smaller bridge step, no prefill and decode pairing, no wait for the router |
| Run:ai | GPU fractions, swapping GPU memory to CPU RAM, rolling updates per workload | Rolls per workload; its memory swap moves several resident models in and out rather than replacing a version |
| Kueue | When a workload may start | Admission, not the order of replacement |
| Volcano, KAI Scheduler | Which node pods land on: gangs, queues, fair share | Would place the bridge, not retire the old slot |
| HAMi | Which card, and how much of its memory | Makes two engines fit on one card; has no notion of a model version |
The bridge: a small copy of the new model
The answer is a bridge: a complete copy of the new model, prefill and decode, given only as much memory as the old engine leaves free. It carries traffic while the old model leaves and the full-size new one loads.
0.70 + 0.27 is what fits: 270.4 to 270.6 GB of 275 GB per card while both engines share it. 0.70 + 0.30 does not. The first attempt refused to start with:
Free memory on device ... is less than desired GPU memory utilization
An engine set to 0.70 holds 0.70 × 267.69 GiB plus about 3 GiB of CUDA context and buffers, so the arithmetic on the flag alone overstates the room.
DynamoSwap: one custom resource and a 10-second loop
We added a Kubernetes custom resource, DynamoSwap. One manifest holds spec.model, a stable served name, and a worker spec written like a DynamoGraphDeployment with one prefill and one decode. To change the model we edit spec.model and push, and Argo CD applies it. A Python controller reconciles every 10 seconds and renders each step as its own workers-only DynamoGraphDeployment, which we call a slot. The DynamoSwap owns its slots, so Argo CD never prunes them.
Discovery needed no code. A frontend-only graph watches the namespace, every slot registers under the same served name, and the frontend routes only to slots that have both a prefill and a decode. A prefill and its decode always come from the same version.
| Phase | What runs | Moves on when |
|---|---|---|
Serving | old model at 0.70 | spec.model changes |
Bridging | adds the new model at 0.27 | every frontend has routed a request to it |
DrainingOld | old slot: prefill to 0, then the whole slot | its pods are gone |
Loading | adds the new model at 0.70 | every frontend has routed a request to it |
Finalizing | bridge: prefill to 0, then the whole slot | its pods are gone |
Two rules keep it safe:
- Routed is checked, not assumed. Every frontend pod must list the slot's prefill and decode in
/healthand show adynamo_frontend_worker_*series for its decode in/metrics. With no live traffic, the controller sends its own probe requests. - It fails safe. A bridge that is not routed within 30 minutes is removed and the old model keeps serving. A 0.70 engine that fails twice leaves the swap on the bridge, marked
Degraded.
Three requests lost, then none
We tested on one lab node under steady load: 6 short in-cluster streams at about 10 requests per second, 2 long streams of 1,500 to 3,000 tokens, and 4 streams through a test proxy. A request normally took 0.62 s.
Run 1 deleted the old slot whole once the bridge was routed. 3 of 13,560 requests failed, all at the moment of the delete, 08:42:31 Malaysia time (MYT):
503 no backend worker available
The old decode unregistered 17 ms before its prefill. For those 17 ms the frontend still saw a prefill to send requests to, and the decode they needed was gone.
The fix is ordering. Scale the old prefill to 0 first. A slot with no prefill is incomplete, so the frontend stops sending it new requests at once. Requests it already prefilled finish on its decode, which is deleted only after the prefill pod is gone, with DYN_GRACEFUL_SHUTDOWN_GRACE_PERIOD_SECS=60 so in-flight streams can drain. The default is 5 seconds, which cut a stream in our first test by hand.
Show the data
| Time (MYT) | Event |
|---|---|
| 08:59:45 | Bridge at 0.27 started |
| 09:09:24 | Bridge routed; old prefill scaled to 0 |
| 09:11:14 | Old slot deleted |
| 09:12:25 | New 0.70 slot started |
| 09:22:04 | New slot routed |
| 09:23:54 | Bridge deleted |
| 09:25:14 | Serving |
Run 2 lost none of its 15,381 requests. Request time stayed at 0.62 s except in the last 5 to 6 minutes of each new engine's load, when it rose to between 1.4 and 3.1 s; the highest 30-second mean was 3.09 s. That is not the swap logic. We attribute it to the new engine compiling and tuning itself (torch.compile, CUDA graph capture and FlashInfer autotuning) on cards a serving engine is using, while the GPU driver time-slices each card between the two processes, giving each a turn.
In production
The same controller then took over production from a hand-written graph and changed its layout on the way, keeping the same model version. Tensor parallelism (TP) splits each layer of the model across GPUs, and TP4 uses four. Production moved from TP4 prefill and TP4 decode on one node to TP8 prefill on one node and TP8 decode on the other, through a TP8 bridge. The move ran from 14:50 to 15:46 MYT, and a probe sent a request through the public API about every 3.5 s for the whole hour. For each phase we report the median, the 95th percentile (p95, the time 95% of probes beat) and the slowest probe.
Show the data
| Phase (MYT) | Probes | Not 200 | Median | p95 | Max |
|---|---|---|---|---|---|
| Old model only, 14:42–14:58 | 540 | 0 | 0.63 s | 0.83 s | 2.21 s |
| f1 refused by the frontends, 14:58–15:10 | 416 | 1 | 0.65 s | 0.88 s | 2.65 s |
| Old + f1 serving, 15:10–15:12 | 76 | 0 | 0.60 s | 1.11 s | 6.20 s |
| f1 only, 15:12–15:16 | 152 | 0 | 0.63 s | 0.87 s | 2.65 s |
| f1 + bridge loading, 15:16–15:27 | 346 | 0 | 0.68 s | 1.64 s | 6.54 s |
| Bridge only, 15:27–15:31 | 102 | 0 | 0.64 s | 0.88 s | 8.71 s |
| Bridge + f2 loading, 15:31–15:43 | 348 | 0 | 0.78 s | 2.22 s | 6.99 s |
| f2, new layout, from 15:43 | 242 | 0 | 0.63 s | 0.94 s | 5.64 s |
Two things went wrong. The frontends refused the first new slot because its alias collided with the old graph's primary model name. The controller's checks caught that before any user traffic reached the slot, and we fixed it by giving every slot the same single primary name. The second, users could feel: the warm-up overlap raised p95 from 0.83 s to as much as 2.22 s.
The frontends logged 237 errors in the window. 232 were the controller's own probes against a slot the frontends had not accepted yet, and 5 were clients hanging up, one of them after waiting 7.0 s for the first token.
After the move, with two nodes at 0.70 instead of one:
| Measure | Before: TP4 + TP4, one node | After: TP8 + TP8, two nodes |
|---|---|---|
| KV cache capacity, prefill | 2,160,320 tokens | 3,062,272 tokens |
| KV cache capacity, decode | 2,186,304 tokens | 3,121,984 tokens |
| Time to first token (TTFT), mean | 238 ms | 215 ms |
| TTFT p50 / p90 | 201 / 431 ms | 175 / 391 ms |
| TTFT p99 | 879 ms | 1,491 ms |
| Mean time between tokens | 5.0 ms | 4.3 ms |
| Mean request time | 725 ms | 520 ms |
| Load | 4.1 req/s | 4.6 req/s |
These are Dynamo frontend histograms in VictoriaMetrics. Before is 13:40 to 14:40 MYT. After is 15:46:30 to 15:51 MYT, only 1,307 requests, so the after p99 rests on few samples. Memory in use after the move was 195 GB per card on node 1 and 193 GB on node 2. The model still found 9 of 9 codes hidden in prompts of up to 16,000 tokens, and passed 6 of 6 text, image and JSON checks.
Handing a node back to training
The same mechanism moves capacity, not only versions. To free the second node for a training run, one spec.graph edit moved production from TP8 + TP8 across two nodes to TP4 prefill on GPUs 0 to 3 and TP4 decode on GPUs 4 to 7 of the first node.
The first attempt used a 0.27 bridge and ran out of CUDA memory beside the TP8 prefill's 196,186 MiB per card. The controller never left Bridging, the old slot kept serving, and no user noticed. With the bridge at 0.23 it went through.
Going back is a git revert of that commit. We have not run it yet.
When only the weights change: reload in place
Most of our version changes are a new checkpoint of the same model: the same architecture, config.json, tokenizer and chat template, with different weight shards. That does not need a new engine. Dynamo's worker exposes update_weights_from_disk, built for reinforcement learning (RL) training loops.
The controller checks the new shards against the serving model's config, tokenizer, template and tensor names. If only the weights differ, it pauses both engines, reloads prefill and decode in parallel, resumes them, and checks that both report the new version. Anything else goes through the bridge. A restarted worker would come back on whatever model its manifest names, so --model points at a symlink on the node that the controller flips before each reload.
| Pause mode | Pauses measured | Requests | Failed | Trade-off |
|---|---|---|---|---|
wait | 9.7 s, 16.8 s | 2,225 | 0 | in-flight requests finish on the old weights (6.6 s and 12.5 s); worst first token 21.6 s |
keep | 3.0 s, 3.1 s | 2,258 | 0 | an in-flight answer can mix two versions |
The weight reload itself took 2.9 to 4.2 s, as vLLM reported it. Two later runs driven by the controller paused for 10.3 s (7.2 s draining, 3.1 s loading, 0 of 745 failed) and 16.3 s (13.4 s draining, 2.9 s loading, 0 of 644 failed). The reload matches a fresh start. After v15 → v20a → v15 on one engine, the top five token probabilities on 12 prompts matched a freshly started engine to four decimal places.
Where a cold start goes, and cache seeding
Reading the weights is not the slow part. Loading 23 GB from the node's local NVMe drive takes 2.3 to 4.2 s. The rest of the time goes on compilation and tuning.
| Stage | Prefill | Decode |
|---|---|---|
| Pod start to model load | about 60 s | about 60 s |
| Model load | 14.5 s (weights 2.3 s) | 17.8 s (weights 4.2 s) |
| torch.compile | 85 s | 78 s |
| CUDA graph capture for profiling | 46 s | 75 s |
| FlashInfer autotune | about 120 s | about 120 s |
| Final CUDA graph capture | 72 s | 122 s |
| Created to Ready | 8 min 21 s | 9 min 33 s |
All of it is cacheable, but the cache keys include the model and the parallel layout, so a new version or a new node starts cold. Since controller 0.3.0, a seed Job runs on each node before a slot's engines start. It copies the namespace's warm vLLM, FlashInfer and Triton caches from a shared NFS store into the node's cache directory, and a publish Job copies new entries back once the slot serves. spec.cache takes Seed or Cold and defaults to Seed. A failed Job, no result within 300 s, or no store falls back to a cold load.
Full lab swaps with compile caches took 23 min 19 s and 22 min 38 s, and none of their 11,872 and 13,340 requests failed.
What it costs
- A bridge swap takes 22 to 26 minutes, because the new model loads twice. Reload in place covers the common case in seconds.
- Latency rises during the overlap. Medians hold at 0.60 to 0.78 s, but p95 reaches 1.64 to 2.22 s and single requests 6 to 9 s while two engines take turns on the same cards. Swap off-peak, or run both engines under CUDA MPS (Multi-Process Service) with a cap on each. A follow-up post on GPU time-slicing covers what we measured.
- Streams longer than the 60-second grace period on a removed decode are still cut.
- It relies on prefix discovery. If a future Dynamo makes strict namespace matching the default, slots will stop being found. The sign is the frontend no longer logging
Adding worker setafter an upgrade.
Summary
With every GPU already serving, a stock rolling update has nowhere to put the new engine, and it rolls prefill and decode apart. A bridge at 0.27 of each card carries traffic while the old pair leaves and the new 0.70 pair loads. A small controller sequences it, draining prefill before decode and waiting for the router before deleting anything. The lab run moved 15,381 requests without a failure, production changed layout with 2,339 of 2,340 probes answered, and handing a node back to training lost 0 of 1,320.
If you are doing the same thing, here is what we'd recommend:
- Measure what an engine really holds, not what its utilisation flag says. 0.70 + 0.30 looked like it would fit and did not.
- Retire a disaggregated slot prefill first. Deleting both halves together opened a 17 ms window that cost 3 requests.
- Gate on the router, not on Ready. Check that every frontend lists the new slot and has sent it traffic.
- Use the cheapest path that fits the change: reload in place for new weights, a bridge swap for anything else, and the stock rollout when you have spare GPUs.
- Seed compile caches. Reading the weights takes seconds; compilation takes minutes.
- If two engines must share cards, use MPS and cap every client. Uncapped, two TP4 engines deadlocked in our follow-up tests.