A long-running pricing service loaded `models:/room-rate-prod@champion` from the MLflow registry; after on-call moves `champion` back a version, why does it still score with the newer one?
answer
- the registry does not push
- resolved once, when the URI is loaded
- files downloaded, object held in memory
- reload or restart picks up the move
- get_model_version_by_alias, then load by number
basics
~20 sAn MLflow alias is resolved when the URI is loaded: load_model asks which version champion names, downloads it and keeps that object. Moving the alias changes only what the next load gets, so the service must reload or restart.
solid answer
~40 s`mlflow.pyfunc.load_model("models:/room-rate-prod@champion")` turns the alias into a name and version number at load time, downloads that version's files and returns an in-memory model. Nothing in that object re-checks the registry, so a process that loaded version 14 keeps scoring with 14 until it loads again. A nightly batch job that loads at start picks up the rollback on its next run; a long-running service needs a restart or an explicit reload, and `mlflow models serve` likewise resolves the URI once at startup. A robust pattern is to call `get_model_version_by_alias` at startup, log the version number, then load `models:/room-rate-prod/<version>`, so the logs say exactly which version was serving. And if someone deleted the version an alias named, the alias is gone too and the next load fails.
go deeper
Recall that models:/name@alias is turned into a version number when the model is loaded, and that a running program keeps what it loaded.
Explain the load path: resolve the alias, download the version's files, build the object, and why a batch job and a service pick up a move at different times.
Diagnose the stuck rollback, make the resolved version visible per process, and know that deleting the aliased version breaks the next load.
Decide where alias resolution lives in the platform: in each service at startup, in a deploy step that pins numbers, or both, and what each costs on a rollback.
## The symptom A pricing service loaded `models:/room-rate-prod@champion` when it started, at which point `champion` named version 14. Prices look wrong, so the on-call engineer calls `set_registered_model_alias("room-rate-prod", "champion", "13")`. The registry UI shows `champion` on 13, yet the service keeps quoting the same prices. Nothing is broken; this is how an alias URI works. ## When an alias is resolved An alias is resolved **when the URI is loaded**, not continuously: 1. `mlflow.pyfunc.load_model("models:/room-rate-prod@champion")` (or a flavor's `load_model`) asks the registry which **name and version** the alias currently names. 2. MLflow gets that version's download location and **downloads its files** to the local disk. When it downloads a whole model directory from a `models:/` URI it also writes a small `registered_model_meta` file recording the model name and version. 3. The flavor builds the model object in memory and returns it. After step 3 the object is just a model. It holds no subscription to the registry, and the registry has no list of processes to notify. The docs put it from the other side: if the alias is reassigned, "the next execution" of the load picks up the new version. | Consumer | When it resolves `@champion` | When a moved alias takes effect | |---|---|---| | nightly batch job loading at start | each run | the next run | | long-running service loading once | at startup | after a restart or explicit reload | | `mlflow models serve -m models:/...@champion` | when the server starts | after the server restarts | | deploy script calling `get_model_version_by_alias` | on each call | immediately, for what it deploys next | ## Making the rollback take effect - **Move the alias, then reload.** The alias move records the decision; a rolling restart, or a reload hook in the service, makes processes act on it. How traffic is ramped across replicas is a rollout-design subject; MLflow's part ends at what each load resolves to. - **Resolve explicitly and log it.** At startup call `client.get_model_version_by_alias("room-rate-prod", "champion")`, write the returned version number to the logs and metrics, then load `models:/room-rate-prod/<version>`. Every replica then reports exactly what it serves, and a mismatch between the registry and a replica is visible. - **Pin by number where you need certainty.** A deployment manifest that names `models:/room-rate-prod/13` changes only when the manifest changes; the alias stays the human-facing record of intent. ## The failure modes around it - **Some replicas reloaded, some did not.** Two replicas started at different times can resolve `@champion` to different versions. Logging the resolved version per process is the only way to see it. - **A deleted version takes its aliases with it.** `delete_model_version` removes every alias on that version. A restart after such a delete fails with "Registered model alias champion not found" instead of falling back, so a crash-looping service can be the first sign. - **A cache between you and the registry.** If a deployment tool copies the files once and serves the copy, moving the alias changes nothing until that tool runs again. - **Expecting an alias to track the newest version.** Registering version 15 does not move `champion`; only `set_registered_model_alias` does. ## The registry half of a rollback runbook 1. Read the current holder with `get_model_version_by_alias("room-rate-prod", "champion")` and note the number you are leaving. 2. Move the alias to the target, typically the version under `previous-champion`, with `set_registered_model_alias`. 3. Confirm with `get_model_version_by_alias` that `champion` now names the target. 4. Trigger the reload or restart for every consumer that resolves `@champion` once. 5. Check each process's logged version number until every replica reports the target. Steps 1-3 take seconds; step 4 is where the minutes go, and step 5 is the only proof the rollback reached production. ## What to say in the interview - An alias is a pointer that is **read at load time**; a loaded model is a snapshot of whatever the pointer named then. - Rollback in the registry is **one call**, and making it reach running processes is a **reload**. - Make the resolved **version number observable** in every process, so "which version is serving" is answered from logs rather than from the registry page.
- How can a running service report which registry version it actually loaded?Resolve the alias yourself: call `get_model_version_by_alias("room-rate-prod", "champion")` at startup, log the returned `version`, then load `models:/room-rate-prod/<version>`. MLflow also writes a `registered_model_meta` file with the model name and version into a model directory it downloads from a `models:/` URI, but an explicit log line is easier to query.
- Does registering a new version 15 change what `@champion` loads?No. An alias moves only when `set_registered_model_alias` is called. Version 15 exists alongside the others, and `models:/room-rate-prod@champion` keeps resolving to whatever version the alias was last set to.
- A loaded model watches the registry and swaps itself when the alias moves.
- Moving the alias rolls back every running replica within seconds.
- An alias automatically moves to each newly registered version.
- If the aliased version is deleted, the alias falls back to the previous version.
- mlflow models serve re-resolves the alias on every request it scores.