Retraining triggers, canary checks and model rollback
Define retraining triggers, run shadow or canary checks, promote through a model registry and roll back to the previous version.
By Invicly Tech, , in AI and Machine Learning with Python. About 11 minutes to read.
In short
Models age, so you need clear rules for when to retrain, how to test a new version safely and how to go back if it misbehaves. A model registry stores numbered versions and lets you point a named alias such as champion at the one in use. Promotion then means moving the alias after shadow or canary checks pass, and rollback means moving it back.
Think of it like this: The champion alias is like a signpost: you do not move the buildings, you just turn the sign to point at a different one.
Explained simply
A model is trained on a snapshot of the past. As time goes on, the world moves away from that snapshot and the model slowly gets worse. Retraining means training again on newer data, using the same tracked pipeline, so you get a fresh version you can compare fairly with the old one.
You need rules for when to retrain. Some teams retrain on a schedule, such as monthly. Others retrain when a monitor fires, such as strong drift or a drop in measured accuracy. Most use both: a regular schedule plus alerts for surprises.
A new version should never go straight to production. It must first beat the current model on recent data, then prove itself on live traffic in shadow or canary mode. Only then is it promoted. A model registry keeps every version, and aliases such as champion say which one is live.
Things still go wrong, so rollback must be quick and practised. With aliases, rolling back means pointing champion at the previous version. Because the old version was never deleted, the switch takes seconds and needs no new code.
Press Play on a diagram to walk through it one step at a time.
- 1Trigger
Schedule, drift or performance drop
- 2Retrain
Fresh data, same tracked pipeline
- 3Offline gate
Beat champion and baseline on holdout
- 4Shadow or canary
Live traffic, guardrails watched
- 5Promote
Move the champion alias
- 6Monitor
Roll back if guardrails break
- Back to step 1
- 1Detect
Guardrail breached or incident raised
- 2Decide
Owner confirms rollback, no debate needed
- 3Move alias
champion back to the previous version
- 4Verify
model_version in responses, metrics recover
- 5Review
Record cause, fix, add a test
In depth
Choosing retraining triggers
There are three kinds of trigger. Time-based triggers retrain on a fixed schedule, which is simple and predictable but may retrain when nothing changed, or wait too long after a sudden shift. Drift-based triggers fire when input drift passes a threshold for long enough, for example PSI over 0.25 on a top feature for two weeks. Performance-based triggers fire when a labelled metric falls below a floor, which is the most direct signal but arrives late when labels are delayed.
Write triggers down with numbers. Add a minimum gap between retrains and a minimum amount of new labelled data, so noise does not cause constant retraining. A trigger starts a retraining run; it never promotes a model by itself.
- Time: monthly or quarterly schedule
- Drift: threshold held for a set period
- Performance: metric below a floor on mature labels
- Guards: minimum new data and minimum gap
- A trigger retrains; gates decide promotion
Promotion gates and registry aliases
A promotion gate is a list of checks a challenger must pass. Offline: it beats the champion and the naive baseline on the same recent holdout, does not get worse on key slices, and passes the parity and contract tests. Online: shadow or canary guardrails hold for an agreed period.
In the MLflow model registry, each registered model has numbered versions. Aliases are named pointers to one version; code loads models:/churn@champion and gets whatever version the alias points to. MLflow deprecated the older Staging and Production stages in version 2.9 in favour of aliases and tags. Use tags on versions to record gate results, such as validation_status = passed, and the approver.
- Training job to Model registry: Register version 81Register version 8
- Model registry to Gate checks: Set alias challenger on version 82Set alias challenger on version 8
- Gate checks to Model registry: Offline and canary checks passed, tag version3Offline and canary checks passed, tag version
- Gate checks to Model registry: Owner moves champion from version 7 to 84Owner moves champion from version 7 to 8
- Serving to Model registry: Load models:/churn@champion5Load models:/churn@champion
Shadow and canary checks for models
In a shadow check, the challenger scores the same live requests as the champion, but only the champion's answers are used. You compare the two: how often they agree, how their score distributions differ, and their latency and error rates. Large disagreement is not always bad, but every big difference should be explainable.
In a canary, a small share of traffic, often 1 to 10 percent, gets the challenger's answers. Choose guardrails before starting: service metrics such as p95 latency and errors, and business metrics such as conversion or complaints. Keep the canary running long enough to cover normal weekly patterns. For batch models, score both versions on the same data, compare distributions and spot-check samples before switching the output.
Feedback loops
A feedback loop appears when the model's decisions decide which outcomes you get to see. A credit model rejects risky applicants, so you never learn whether they would have repaid. A recommender shows some products more, so they get more clicks and look even better next time. Retraining on this data teaches the model its own past choices.
Ways to reduce it: keep a small random holdout group that receives a default treatment, so you see unbiased outcomes. Log the model score and decision with each outcome, so you can correct for selection. Watch for narrowing, such as fewer distinct products recommended over time. And be careful about letting a model retrain and promote itself automatically.
- Keep a small random control group
- Log decisions with outcomes
- Watch diversity and coverage over time
Learn it in 5 short steps
About 35m each. Track them with a timer in your plan.
- 1Define retraining triggers~35m
- 2Run shadow and canary checks~35m
- 3Promote with registry aliases~35m
- 4Guard against feedback loops~35m
- 5Roll back to the last good model~35m
Key points
- Retraining triggers can be time-based, drift-based or performance-based; most teams combine a schedule with alerts.
- A new version must beat the current champion on the same recent holdout, not just on its own validation data.
- MLflow registry aliases (for example champion and challenger) replace the older, deprecated stages.
- Feedback loops happen when the model's own decisions shape its future training labels.
- Rollback should be one tested step: point the alias at the previous version.
Key terms
Tap a card to flip it. 0/6 known
Examples
from mlflow import MlflowClient
client = MlflowClient()
name = "churn"
old = client.get_model_version_by_alias(name, "champion").version
# promote version 7 after canary checks pass
client.set_registered_model_alias(name, "previous", old)
client.set_registered_model_alias(name, "champion", "7")
# rollback: point champion back at the previous version
client.set_registered_model_alias(name, "champion", old)Promotion and rollback by moving registry aliases.
A gated retraining script
A monthly job retrains the churn model. Step 1: train on the last 12 months with the tracked pipeline. Step 2: evaluate the new version and the current champion on the most recent month, which neither trained on. Step 3: register the new version and set it as challenger. Step 4: only if it beats the champion by an agreed margin, tag it as passed so it can go to canary. Nothing is promoted automatically.
import mlflow
from mlflow import MlflowClient
from sklearn.metrics import roc_auc_score
client, name = MlflowClient(), "churn"
with mlflow.start_run(run_name="monthly-retrain") as run:
new = build_pipeline().fit(X_recent_train, y_recent_train)
info = mlflow.sklearn.log_model(new, name="model", registered_model_name=name)
champ = mlflow.sklearn.load_model(f"models:/{name}@champion")
auc_new = roc_auc_score(y_holdout, new.predict_proba(X_holdout)[:, 1])
auc_old = roc_auc_score(y_holdout, champ.predict_proba(X_holdout)[:, 1])
version = info.registered_model_version
client.set_registered_model_alias(name, "challenger", version)
client.set_model_version_tag(name, version, "gate", "passed" if auc_new >= auc_old + 0.005 else "failed")Rolling back after a bad canary
Version 8 went to a 5 percent canary. After two days, complaints about irrelevant offers rise and the score distribution is shifted. Step 1: the owner decides to roll back, as the runbook allows. Step 2: move champion back to version 7, which was kept as previous. Step 3: confirm responses show version 7 and the score distribution returns to normal. Step 4: tag version 8 with the reason and open a review.
from mlflow import MlflowClient
client, name = MlflowClient(), "churn"
prev = client.get_model_version_by_alias(name, "previous").version
client.set_registered_model_alias(name, "champion", prev)
client.set_model_version_tag(name, "8", "rollback_reason", "offer complaints up in canary")
print("champion now:", client.get_model_version_by_alias(name, "champion").version)Quick reference
- Triggers: time, drift or performance; most teams combine a schedule with alerts
- A trigger starts retraining; only gates allow promotion
- Gate: beat champion and baseline on the same recent holdout, no slice regressions
- client.set_registered_model_alias(name, "champion", version) promotes; repeat with the old version to roll back
- Load by alias: models:/churn@champion
- MLflow stages (Staging, Production) are deprecated; use aliases and tags
- Keep a random control group to limit feedback loops
- Never delete the previous version until the new one is proven
Common mistakes
- Retraining automatically and promoting without a gate, so a bad data week becomes the new production model.
- Overwriting the old model file instead of keeping versions, which makes rollback impossible.
- Training only on outcomes of cases the model approved, so it never learns from the cases it rejected.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Write retraining triggers for a demand forecast with daily labels: one time-based, one drift-based and one performance-based, with numbers.
- Exercise 2medium
Register two versions of a scikit-learn model in a local MLflow registry, set champion on version 1, then promote version 2 while keeping version 1 as previous.
- Exercise 3hard
Write a one-page promotion and rollback policy for a recommender: gates, canary plan, feedback-loop guard and rollback steps.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- How often should I retrain a model?
- It depends on how fast your data changes. Start with a schedule that matches the business cycle, such as monthly, then use monitoring to retrain earlier when needed or less often if performance stays stable.
- Can retraining be fully automatic?
- Retraining can be, but promotion should pass automated gates and, for higher-risk models, a human approval. Fully automatic promotion makes feedback loops and bad data much more dangerous.
- What is the difference between a model version and an alias?
- A version is a fixed, numbered copy of a model that never changes. An alias is a movable name that points at one version, so you can switch versions without changing code.