Sub topic 14
Registering and Promoting Models
Prerequisites: you should understand training, validation, deployment, version control, and the champion-challenger evaluation pattern.
A model registry is a system of record for trained models. It stores each model version with the information needed to identify, evaluate, reproduce, and deploy it. A registry is different from a file store. A file store may contain a model artifact, but a registry connects that artifact to its code version, data version, metrics, and approval state.
What to register
Each training run should produce an immutable model version. Store these details with it:
- The model artifact and its format.
- Training and validation data identifiers.
- Source-code commit and dependency versions.
- Feature definitions and preprocessing configuration.
- Evaluation metrics, test slices, and validation results.
- Training timestamp and run identifier.
- The identity of the person or service that approved it.
- Security, privacy, and license metadata.
Use immutable versions so that a historical deployment can always be reconstructed. Do not replace the file behind an existing version. Create a new version instead.
A registry usually gives versions lifecycle states such as candidate, staging, production, and archived. Some systems use aliases such as champion and challenger. An alias lets serving code refer to the current production model without hard-coding a version number.
| Registry item | Purpose |
|---|---|
| Model version | Identifies one immutable artifact |
| Metadata | Describes data, code, metrics, and dependencies |
| Stage or alias | Selects which version can be deployed |
| Approval record | Shows who or what authorized promotion |
Promotion is an evaluation decision
Training success does not justify promotion. The evaluation gate should compare the challenger with the current champion using the same test protocol. It should check data quality, overall metrics, important segments, latency, resource use, and policy constraints.
A challenger should be promoted only when it passes validation and meets the minimum improvement or non-regression rule. Record the decision and its reason.
from dataclasses import dataclass
@dataclass(frozen=True)
class ModelVersion:
version: str
auc: float
data_ok: bool
def promote(challenger: ModelVersion, champion: ModelVersion,
minimum_gain: float = 0.002) -> tuple[bool, str]:
if not challenger.data_ok:
return False, "data_validation_failed"
gain = challenger.auc - champion.auc
if gain < 0:
return False, "regression"
if gain < minimum_gain:
return False, "gain_below_threshold"
return True, "promote"
champion = ModelVersion("42", 0.905, True)
challenger = ModelVersion("43", 0.912, True)
print(promote(challenger, champion))This example returns a promotion decision, but a real pipeline would also write the result to the registry and require approval for high-risk models.
Promotion flow and failure handling
After promotion, retain the previous champion. If monitoring detects a regression, move the production alias back to that known version. The rollback action should be tested before an incident occurs.
Exercise
Why should a registry keep immutable versions instead of overwriting the current production model?
Show answer
Immutable versions preserve lineage and make comparison, auditing, and rollback possible.