Swapping model on the fly
Credits to Scicom (MSC) Berhad and Scicom AI Enterprise for the resources.
We had a problem: we retrain often, so the model behind the API keeps changing, but every GPU is already serving and there's no spare one to load the new model on. Swapping meant either downtime or squeezing two models onto the same cards. So we built a way to swap on the fly.
Why the stock rollout doesn't fit
Editing a DynamoGraphDeployment lets Dynamo's operator roll each component with maxSurge. On our cards:
- No room for a surge. Engines run at 70% of GPU memory. A second 70% doesn't fit.
- Prefill and decode roll separately. The new prefill must hand off to the new decode.
- Ready isn't routed. A pod passing its probe doesn't mean the router sends it traffic yet.
Doesn't something already do this?
Run:ai has rolling updates, but per workload:
Its GPU memory swap keeps several models on one GPU by paging the idle ones to CPU RAM. That's model multiplexing, not a version swap, and it needs Run:ai's scheduler instead of HAMi:
Kueue decides when a job may start. It doesn't care what replaces what:
Volcano (and KAI) are batch schedulers: gang scheduling, queues, fair share. They'd place the bridge, not retire the old slot:
HAMi is what makes two engines fit on one card. It has no idea what a model version is.
So it became a small operator.
The CRD
A DynamoSwap holds spec.model, a served name, and a worker spec. Edit spec.model, push, Argo CD applies it. A Python loop reconciles every 10 s and creates each step as its own workers-only DynamoGraphDeployment.
- 70% + 27% fits (about 98% of card memory). 70% + 30% doesn't.
- "Routed" is checked: every frontend must list the new slot in
/healthand show traffic to it in/metrics. - Fails safe: a bridge that isn't routed in 30 min is removed, the old model keeps serving.
The failed requests
The first run deleted the old slot whole: 0.02% of requests got 503. The decode unregistered a few milliseconds before its prefill.
Fix: scale the old prefill to 0 first. The router drops an incomplete slot immediately, the decode finishes what's in flight (60 s grace), then it goes. Next run: 0% failed.
Results
| Run | Requests served |
|---|---|
| Lab, old slot deleted whole | 99.98% |
| Lab, prefill first | 100% |
| Production move, one node → two nodes | 99.96% (the one failure was a proxy outside the cluster) |
| Node handed back to training, two nodes → one | 100% |
Two shortcuts
- Reload in place. Same architecture, tokenizer and template, new weights? Pause both engines, call Dynamo's
update_weights_from_disk, resume. About 99% faster than a bridge swap, 0% failed, outputs identical to a fresh engine. - Cache seeding. Reading the weights is under 1% of a cold start; the rest is torch.compile, CUDA graphs and FlashInfer autotune. A Job copies warm caches from NFS to the node before engines start, which cuts startup by roughly 50-65%.
Costs
- A bridge swap loads the new model twice, so it takes tens of minutes.
- Latency spikes while two engines share cards. Swap off-peak or use MPS.
- Streams longer than the 60 s grace get cut.