Quant Memo
Core

Hot-Reloading Models Without Downtime

How a production trading system swaps in a freshly retrained model without ever stopping — and the specific hazards of doing that swap while requests are actively in flight.

Prerequisites: Packaging and Serialising Model Artefacts

A model gets retrained nightly on the latest data, and the production system that serves its predictions runs continuously through the trading day — it can't simply be stopped, updated, and restarted every time a new model is ready, because that would mean going dark during market hours, missing signals and potentially leaving open positions unmanaged for the duration. The system needs a way to swap in the new model while it keeps running, without ever serving from an inconsistent or half-loaded state.

The idea: swap the whole thing atomically, never in pieces

Hot-reloading means replacing a running model with a new one without restarting the service that serves it. The naive approach — load new weights directly into the object currently serving live predictions — is dangerous because "loading" isn't instantaneous: for a brief window, some parts reflect the old weights and some the new, and a request arriving in that window gets served by this inconsistent hybrid, matching neither model.

The standard fix loads the new model into a separate, fully-initialized object off to the side, verifies it, and only then flips a single reference from "requests go to the old object" to "requests go to the new one." That flip is atomic, so any request sees the fully-old or fully-new model, never something in between. The old object stays alive briefly afterward, so a request already in flight can finish against the version it started with.

Worked example: what goes wrong without the atomic flip

A service holds a model as separate pieces — a weights array and a fitted scaler as two different loaded objects — and reloads them one at a time: weights first, scaler second. A request arriving in the brief window between the two gets processed with the new weights but the old scaler — a combination never trained together or tested, effectively an accidental third model nobody designed. Its prediction could be badly wrong, and the failure produces no crash — just a wrong number, indistinguishable from normal output until trading outcomes look strange.

The fix is bundling weights and scaler as one artefact (as in model packaging) and reloading them as a single unit — load a complete new pair off to the side, then flip one reference atomically. There is no window where only half the new artefact is live.

Function explorer
-2222.8
x = 1.00f(x) = 0.000

Loosely, that curve represents "risk of an inconsistent hybrid state" against "how much of the reload happens as one atomic step" — piecing the reload out into several sequential updates keeps that risk elevated for longer, while collapsing it to a single atomic flip drives the exposure window down to effectively zero.

What this means in practice

Hot-reloading is really a concurrency problem dressed up as a deployment problem: the danger isn't loading a new model, it's a request arriving during loading and seeing a torn, half-updated state. The reliable pattern — build the new model fully in isolation, verify it, flip a single reference — generalizes to any live configuration swap, and is worth testing deliberately by sending requests concurrently with a reload rather than assuming the window is "too short to matter."

Safe hot-reloading loads the new model completely, as a separate object, and only then swaps in a single atomic reference change — never updating a live model's individual pieces one at a time — so that any in-flight or incoming request sees a fully consistent old or new model, never an untested hybrid of the two.

Reloading a model's components piecemeal (weights, then a scaler, then a feature list) creates a window where requests can be served by a combination that was never trained or tested together. It produces no crash and no error message — just quietly wrong predictions during the reload window — which makes it one of the harder production bugs to trace back to its cause.

Related concepts

Practice in interviews

Further reading

  • Google, Site Reliability Engineering, ch. on release engineering
ShareTwitterLinkedIn