Sub topic 14
Registering and promoting models
This chapter covers what happens after the evaluation gate says a challenger is good enough. You will learn what a model registry stores, how promotion works, and how to avoid common errors. It assumes you know the basic train, validate, test, deploy workflow, can read Python, and have used version control and CI/CD.
Why a registry sits between training and serving
A retraining pipeline produces a new model file on a schedule or on a trigger. Serving systems need to answer a simple question: which model should I load right now? If the answer is "the newest file in a bucket," you have no history, no audit trail, and no clean way back.
A model registry is a service that stores versioned models together with their metadata and tracks which version is in use. Common examples are MLflow Model Registry, SageMaker Model Registry, and Vertex AI Model Registry. The names differ, but the working model is the same.
A registry gives you three things:
- A stable name for a model, such as
churn-classifier, that does not change when the model is retrained. - An immutable version for each trained artifact, such as
churn-classifierversion 14. - A pointer that says which version serves production.
The pointer is the part that matters most for promotion. Promotion changes the pointer. It does not copy, retrain, or rebuild anything.
What to record with each version
A model file alone is not enough. When version 14 misbehaves at 2 a.m., you need to know how it was made. Store the following with each registered version:
| Field | Example | Why it matters |
|---|---|---|
| Artifact URI | `s3://models/churn/14/model.pkl` | Where serving loads the model from |
| Training data version | `snapshot-2026-11-28` | Reproduce or audit the training set |
| Code version | Git commit `a1b2c3d` | Reproduce the training run |
| Metrics | AUC 0.912 on the holdout set | Compare versions, justify promotion |
| Trigger reason | `drift_with_enough_data` | Explain why this run happened |
| Input schema | Feature names and types | Detect mismatches at serving time |
| Gate result | `promote` | Record the decision and its reason |
This is the lineage from the previous chapter, attached to the version. The trigger reason and gate result come from the trigger policy and evaluation gate you have already built. Recording them turns the registry into an audit log of every decision the pipeline made.
Stages and aliases
Most registries let a version sit in a named stage or carry a named alias. Older MLflow versions used fixed stages such as Staging and Production. Newer versions favor aliases, such as champion and challenger, because aliases are more flexible and map directly to the champion-challenger pattern.
A typical lifecycle looks like this:
Note that failed models are still registered. Keeping rejected versions with their metrics and failure reasons helps you debug the pipeline later. A challenger that failed three runs in a row for gain_below_threshold tells a different story from one that failed on data_validation_failed.
Promotion as a pointer change
Promotion should be a small, fast, reversible operation. The sketch below uses a toy in-memory registry to show the logic. A real registry exposes the same operations through its API.
from dataclasses import dataclass, field
@dataclass
class Version:
number: int
auc: float
data_version: str
code_version: str
trigger_reason: str
status: str = "registered"
@dataclass
class Registry:
versions: dict = field(default_factory=dict)
aliases: dict = field(default_factory=dict)
def register(self, auc, data_version, code_version, trigger_reason):
number = len(self.versions) + 1
self.versions[number] = Version(
number, auc, data_version, code_version, trigger_reason
)
return number
def promote(self, number):
previous = self.aliases.get("champion")
if previous is not None:
self.versions[previous].status = "archived"
self.versions[number].status = "production"
self.aliases["champion"] = number
self.aliases["previous"] = previous
return previous
def rollback(self):
previous = self.aliases.get("previous")
if previous is None:
raise RuntimeError("no previous version to roll back to")
current = self.aliases["champion"]
self.versions[current].status = "archived"
self.versions[previous].status = "production"
self.aliases["champion"] = previous
self.aliases["previous"] = None
return previous
registry = Registry()
v1 = registry.register(0.905, "snap-1", "a1b2c3d", "max_model_age")
registry.promote(v1)
v2 = registry.register(0.912, "snap-2", "a1b2c3d", "drift_with_enough_data")
registry.promote(v2)
print(registry.aliases)
registry.rollback()
print(registry.aliases)Two details are worth noticing. First, promote remembers the previous champion, so rollback needs no search and no retraining. Second, versions are never deleted or edited in place. Only the alias and the status change.
Connecting the gate to the registry
The evaluation gate decides. The registry records and applies the decision. Keep these two roles separate in your pipeline code so that you can test each one alone.
A common flow is:
- Train the challenger and register it with its metrics and lineage.
- Run the gate against the current champion, using the same holdout data for both.
- If the gate returns
promote, set thechallengeralias, then deploy it through the rollout path (shadow or canary, covered in the next chapter). - Only after the rollout checks pass, move the
championalias to the new version. - If the gate rejects the model, record the reason on the version and leave the alias alone.
Step 4 matters. Setting the champion alias at the moment the gate passes is a frequent mistake. The gate tests offline metrics. It does not tell you whether the model works behind the real serving stack. Treat the offline pass as permission to start a rollout, and the rollout result as permission to promote.
How serving picks up a new version
There are two common ways for serving to learn about a promotion.
- Resolve at load time. The server asks the registry for
models:/churn-classifier@championwhen it starts or reloads. This is simple, but a running server does not notice changes until it reloads. - Pin at deploy time. The deployment configuration names an exact version, and promotion means updating that configuration through CI/CD. This is more explicit and leaves a Git history, but it adds a step.
Pinning an exact version is safer in regulated settings because the deployed state always matches a reviewed change. Resolving an alias is faster to operate. Whichever you choose, log the version number with every prediction. Without it you cannot connect a bad outcome to the model that produced it, and the performance triggers from earlier chapters depend on that join.
Common errors
- Mutable artifacts. Overwriting
model.pklat the same URI breaks the link between a version number and its behavior. Write each version to a new path and treat it as immutable. - Promoting without the schema. If the new model expects a feature the serving code does not provide, it fails at runtime. Store the input schema and check it before promotion.
- Comparing against a stale champion metric. The champion's AUC stored at its registration time was measured on older data. For a fair comparison, re-evaluate both models on the same current holdout set.
- Missing previous-version pointer. If you cannot find the last good version quickly, rollback becomes an incident. Record it at promotion time, as the sketch above does.
- Unbounded version growth. Retraining weekly creates dozens of versions a year. Archive old artifacts on a retention policy, but keep the metadata and lineage permanently.
- No approval record. In settings that require review, store who approved a promotion and when, as part of the version metadata.
Human approval in the promotion step
Fully automatic promotion suits low-risk models with strong gates. For higher-risk models, add a manual approval between "gate passed" and "alias moved." The pipeline registers the version, posts the metrics and the comparison against the champion, and waits. Registries and CI systems support this with approval states or protected environments. The next-but-one chapters on guardrails return to this choice.
Exercise
Your gate passes a challenger, and your pipeline immediately moves the champion alias to it. Two hours later the serving error rate rises because the model needs a feature the online feature store does not provide. Name two changes to the pipeline that would have prevented the outage or made recovery fast.
Show answer
First, store the input schema with each version and check it against the serving feature set before promotion, which catches the missing feature before any traffic is affected. Second, move the champion alias only after a shadow or canary rollout passes, and record the previous champion at promotion time so rollback is a single pointer change. A third acceptable answer is to log the model version with every prediction so the faulty version is identified immediately.
Exercise
Why should the pipeline register a challenger that failed the evaluation gate instead of discarding it?
Show answer
A rejected version, stored with its metrics and failure reason, is part of the pipeline's audit trail. It lets you see patterns such as repeated gain_below_threshold results or data_validation_failed runs, which point to problems in the data, the trigger policy, or the gate thresholds rather than in a single model.