Skip to main content
Scicom AI

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:

ToolWhat it decidesWhy it does not swap our pair
Dynamo operatorRolls each component with maxSurge and maxUnavailableNo smaller bridge step, no prefill and decode pairing, no wait for the router
Run:aiGPU fractions, swapping GPU memory to CPU RAM, rolling updates per workloadRolls per workload; its memory swap moves several resident models in and out rather than replacing a version
KueueWhen a workload may startAdmission, not the order of replacement
Volcano, KAI SchedulerWhich node pods land on: gangs, queues, fair shareWould place the bridge, not retire the old slot
HAMiWhich card, and how much of its memoryMakes 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.

Each column is one GPU's memory. A slot is one prefill engine and one decode engine; every card in the slot goes through the same five phases.Diagram, not measured data. Bar heights are the configured memory fractions.

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.

PhaseWhat runsMoves on when
Servingold model at 0.70spec.model changes
Bridgingadds the new model at 0.27every frontend has routed a request to it
DrainingOldold slot: prefill to 0, then the whole slotits pods are gone
Loadingadds the new model at 0.70every frontend has routed a request to it
Finalizingbridge: prefill to 0, then the whole slotits 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 /health and show a dynamo_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.

All three failures were 503s at the moment of the delete. Push-to-Serving times include both model loads.Lab load logs, one node, 21 Nov 2026.
Show the data
Run 2 events
Time (MYT)Event
08:59:45Bridge at 0.27 started
09:09:24Bridge routed; old prefill scaled to 0
09:11:14Old slot deleted
09:12:25New 0.70 slot started
09:22:04New slot routed
09:23:54Bridge deleted
09:25:14Serving
The bridge served 940 requests in 80 s on its own. The 2 long-stream loops sent 378 requests, and none failed. Push to Serving was 25 min 44 s; the chart starts when the bridge started.Lab load logs, 21 Nov 2026. Two tunnel errors at 08:41:20 and 09:22:46 never reached the lab and are not counted.

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
Probe latency per phase
Phase (MYT)ProbesNot 200Medianp95Max
Old model only, 14:42–14:5854000.63 s0.83 s2.21 s
f1 refused by the frontends, 14:58–15:1041610.65 s0.88 s2.65 s
Old + f1 serving, 15:10–15:127600.60 s1.11 s6.20 s
f1 only, 15:12–15:1615200.63 s0.87 s2.65 s
f1 + bridge loading, 15:16–15:2734600.68 s1.64 s6.54 s
Bridge only, 15:27–15:3110200.64 s0.88 s8.71 s
Bridge + f2 loading, 15:31–15:4334800.78 s2.22 s6.99 s
f2, new layout, from 15:4324200.63 s0.94 s5.64 s
The median holds through every phase. The slowest single requests come while an engine loads on shared cards, or at a handover.Production probe log, 21 Nov 2026, 14:42 to 15:53 MYT.

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:

MeasureBefore: TP4 + TP4, one nodeAfter: TP8 + TP8, two nodes
KV cache capacity, prefill2,160,320 tokens3,062,272 tokens
KV cache capacity, decode2,186,304 tokens3,121,984 tokens
Time to first token (TTFT), mean238 ms215 ms
TTFT p50 / p90201 / 431 ms175 / 391 ms
TTFT p99879 ms1,491 ms
Mean time between tokens5.0 ms4.3 ms
Mean request time725 ms520 ms
Load4.1 req/s4.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.

Node 1 peaked at 264.6 of 275 GB per card. KV cache capacity on TP4 + TP4: 1.648M tokens prefill, 1.676M decode.Production probe log and hand-back checklist, 21 Nov 2026.

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 modePauses measuredRequestsFailedTrade-off
wait9.7 s, 16.8 s2,2250in-flight requests finish on the old weights (6.6 s and 12.5 s); worst first token 21.6 s
keep3.0 s, 3.1 s2,2580an 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.

StagePrefillDecode
Pod start to model loadabout 60 sabout 60 s
Model load14.5 s (weights 2.3 s)17.8 s (weights 4.2 s)
torch.compile85 s78 s
CUDA graph capture for profiling46 s75 s
FlashInfer autotuneabout 120 sabout 120 s
Final CUDA graph capture72 s122 s
Created to Ready8 min 21 s9 min 33 s
Reading the weights, picked out inside the model load, takes 2.3 to 4.2 s. Almost all the rest is compiling and tuning, and all of it is cacheable.Engine logs, lab, 21 Nov 2026. Stages given as about 60 s and about 2 min are drawn at those values.

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.

On the seeded node the compiled graph loaded on all 8 ranks in 1.3 s, and 80 FlashInfer tuning configs were reused. The store holds 15 GB.Lab runs, 21 Nov 2026.

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 set after 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.

Sources

← Back to the Newsroom