In the MLflow Model Registry, how do aliases such as `@champion` promote and roll back a `room-rate-prod` model version?
answer
- a movable name, not a stage
- one name, one version at a time
- set_registered_model_alias with a version
- models:/<name>@<alias>
- latest and v-number names are reserved
basics
~20 sMlflowClient.set_registered_model_alias(name, alias, version) points an alias such as champion at exactly one version; calling it again moves the alias, so promotion and rollback are the same call with a different version. A version may carry several aliases.
solid answer
~40 sAn alias is a mutable, named pointer from a registered model to one of its versions. `client.set_registered_model_alias("room-rate-prod", "champion", "14")` promotes version 14; if `champion` was on 13 it leaves 13, because a registered model holds each alias name once. Rolling back is the same call with `"13"`. Consumers address the alias as `models:/room-rate-prod@champion`, and `get_model_version_by_alias` returns the `ModelVersion` it names right now. One version can carry several aliases, such as `champion` and `previous-champion`. `delete_registered_model_alias` removes a pointer. Alias names use letters, digits, `_` and `-`; `latest` and names like `v9` are reserved. The registry keeps only the current mapping, so record the outgoing version yourself before you move the alias.
code
python · 14 linesfrom mlflow import MlflowClient
client = MlflowClient(tracking_uri="http://mlflow.internal.example:5000")
name = "room-rate-prod"
# Promote version 14, keeping a pointer to the outgoing champion
outgoing = client.get_model_version_by_alias(name, "champion").version
client.set_registered_model_alias(name, "previous-champion", outgoing)
client.set_registered_model_alias(name, "champion", "14")
# Roll back: the same call, pointed at the old version
client.set_registered_model_alias(name, "champion", outgoing)
print(client.get_registered_model(name).aliases) # alias -> version mappinggo deeper
Recall that an alias like champion points at one version and that models:/name@champion loads whatever version it points at.
Walk through promotion and rollback as set_registered_model_alias calls, and explain one alias per model versus several aliases per version.
Show the operational habits: record the outgoing version before moving the alias, know that deleting a version drops its aliases, and know the reserved names.
Decide how alias names map to environments and consumers so a single move cannot surprise a team that shares the registered model.
## What an alias is A **model alias** is a mutable, named reference from a **registered model** to one of its **model versions**. The docs describe it as a way to "assign a mutable, named reference to a particular version": `champion` on version 14 of `room-rate-prod` lets code say `models:/room-rate-prod@champion` instead of hard-coding 14. Aliases arrived to replace the deprecated registry stages, and they differ from stages in two ways that matter in production: you choose the names, and one version can carry several of them. ## Promote and roll back with one call Every alias operation is on `MlflowClient`: 1. **Read the current holder:** `client.get_model_version_by_alias("room-rate-prod", "champion")` returns a `ModelVersion`; note its `version`. 2. **Promote:** `client.set_registered_model_alias("room-rate-prod", "champion", "14")`. The alias now names 14. If it named 13 before, 13 loses it in the same write, because the registry stores one row per (registered model, alias name). 3. **Keep a way back:** set a second alias, such as `previous-champion`, on 13, or tag the new version with what it replaced. The registry does not keep a history of where an alias pointed. 4. **Roll back:** `client.set_registered_model_alias("room-rate-prod", "champion", "13")`. Rollback is not a separate API; it is the same move in the other direction. 5. **Retire a pointer:** `client.delete_registered_model_alias("room-rate-prod", "previous-champion")`. Who may make that move and which checks must pass first are policy questions; MLflow's part is the call that records the decision. ## One alias, one version; one version, many aliases | Handle | Points at | Moves? | Typical use | |---|---|---|---| | version number (`/14`) | one version, forever | never | pinning an exact build | | alias (`@champion`) | one version at a time | when you call `set_registered_model_alias` | what production should load | | tag (`validation_status`) | a key-value on many versions | when you set it | status and review records | - An alias name appears **once per registered model**, so `@champion` can never be ambiguous. - A version may hold **several aliases** at once: `champion` and `previous-champion`, or `champion` and a team's own `eu-default`. - `get_registered_model(name).aliases` returns the whole alias-to-version mapping for the model. ## Reading an alias - **By URI:** `mlflow.pyfunc.load_model("models:/room-rate-prod@champion")` resolves the alias, then downloads and loads that version. `mlflow models serve -m "models:/room-rate-prod@champion"` resolves it the same way when the server starts. - **By API:** `get_model_version_by_alias` returns the `ModelVersion` without loading files, which suits a deploy script that logs which number it is about to ship. - An unknown alias raises an error naming it: "Registered model alias champion not found." ## Naming aliases for a pricing release Alias names are free text within the character rules, so a naming convention does real work: - **`champion`** for the version production consumers load, as the docs' own examples use. - **`candidate`** for the version a release is evaluating, so staging tests can load `@candidate` without anyone editing a version number. - **`previous-champion`** for the rollback target, set in the same script that moves `champion`. - **Per-consumer aliases** such as `eu-default` when two consumers of one registered model must be able to move independently. Keep the set small and documented: an alias that nobody remembers setting is an alias that nobody remembers to move back. ## Rules and edge cases - **Names:** alphanumerics, underscores and dashes, up to 255 characters. - **Reserved:** `latest` (in any case) cannot be set, and names of the form `v<number>` such as `v9` or `v42` are reserved too. - **The version must exist:** setting an alias to a missing version fails. - **Deleting a version deletes its aliases:** `delete_model_version` removes every alias pointing at it, so a consumer loading `@champion` afterwards gets the not-found error rather than a fallback. - **Deleting an alias that is not set** is a no-op on the database-backed store. ## What aliases do not do - They do not follow the newest version. An alias moves only when someone calls `set_registered_model_alias`. - They do not change what an already-running process holds; a consumer picks up a move the next time it resolves the URI. - They are not permissions. Separating who may move `champion` in production from who may experiment is done with separate registered models and the server's authentication, not with alias names.
- Which alias names does `set_registered_model_alias` refuse?Empty names, names with characters other than letters, digits, `_` and `-`, names over 255 characters, and two reserved forms: `latest` in any case, which `get_model_version_by_alias` already treats as the latest version, and `v<number>` names such as `v3`. Each raises `INVALID_PARAMETER_VALUE`.
- What happens to `@champion` if someone deletes the version it points at?`delete_model_version` deletes every alias on that version, so `champion` disappears rather than falling back to another version. The next `load_model("models:/room-rate-prod@champion")` fails with an alias-not-found error until someone sets the alias again.
- How do you see every alias on a registered model at once?`client.get_registered_model("room-rate-prod").aliases` returns a dictionary from alias name to version. A single `ModelVersion` from `get_model_version` or `get_model_version_by_alias` also lists its own aliases; `search_model_versions` results may leave aliases unpopulated.
An alias is a name tag clipped to one item on a numbered shelf. Unclip it and clip it to another item, and anyone told to fetch the tagged item brings the new one; each tag hangs on one item at a time, while one item can wear several tags.
- An alias automatically follows the newest version registered under the model.
- One alias can point at two versions so traffic can be split between them.
- Rolling back needs a separate rollback API or the deprecated Archived stage.
- A version can carry only one alias, just as it had only one stage.
- Aliases control who may deploy, so an alias is a permission boundary.