Sub topic 2
Understand What Must Be Rolled Back With the Model
Assume you understand model deployment, production monitoring, version control, and service APIs. A model rollback is safe only when the older model can run correctly with the surrounding system.
A model is part of a deployment unit
A production prediction usually passes through several components:
- Request validation and input schema
- Feature retrieval or preprocessing code
- The model artifact and its weights
- Model-serving code
- Runtime dependencies
- Output formatting and business rules
- Feature stores, caches, queues, and databases
These components form a deployment unit, which is the set of artifacts and services required to produce a valid prediction. The model file is only one part of that unit.
For example, a newer release might use a feature named customer_age_days, while the older model expects customer_age. Restoring only the old model file can cause failures or, worse, valid-looking predictions from the wrong inputs.
| Component | Rollback question |
|---|---|
| Model artifact | Is the exact known-good artifact available and verified? |
| Preprocessing | Does it create the features and encoding the model expects? |
| Serving code | Can it load the model and return the older output format? |
| Schema | Are requests and responses compatible? |
| Dependencies | Do library versions support the older model? |
| State | Can caches, databases, or feature stores provide compatible data? |
Model rollback versus application rollback
A model-only rollback changes the model artifact while leaving serving code and infrastructure unchanged. Use it when the model is compatible with the current deployment and the regression is isolated to model behavior.
A service rollback restores model-serving code, preprocessing, configuration, and dependencies together. Use it when the current code changed the model interface or feature construction.
A full application rollback restores other services as well, such as API gateways, feature pipelines, databases, or business rules. This has a larger blast radius and may undo unrelated fixes.
Choose the smallest scope that restores correct behavior. Before changing anything, identify whether the failing signal comes from predictions, the serving process, input handling, or a downstream consumer.
Check compatibility before switching traffic
Compare the candidate release with the currently deployed release. At minimum, check:
- Model input names, data types, shapes, and allowed ranges.
- Preprocessing and feature definitions.
- Output names, types, and meanings.
- Python or system library versions.
- Configuration such as thresholds and calibration settings.
- Database and feature-store schema versions.
- Cache and message formats.
- Whether the model requires state that the rollback process will remove or overwrite.
A schema migration can make a rollback unsafe. For example, code may have renamed a database column and removed the old one. In that case, restoring an older service requires a backward-compatible migration or a separate compatibility layer.
from dataclasses import dataclass
@dataclass(frozen=True)
class Release:
version: str
input_schema: str
output_schema: str
runtime: str
def compatibility_blockers(candidate: Release, environment: dict) -> list[str]:
blockers = []
if candidate.input_schema != environment["input_schema"]:
blockers.append("input schema mismatch")
if candidate.output_schema != environment["output_schema"]:
blockers.append("output schema mismatch")
if candidate.runtime != environment["runtime"]:
blockers.append("runtime mismatch")
return blockers
candidate = Release("2026.03.08", "features-v3", "scores-v2", "python3.12")
environment = {
"input_schema": "features-v3",
"output_schema": "scores-v2",
"runtime": "python3.12",
}
blockers = compatibility_blockers(candidate, environment)
print("compatible" if not blockers else f"blocked: {blockers}")Exercise
The previous model expects the old output field risk_score, but the current API and downstream billing service require risk_probability. Should you perform a model-only rollback?
Show answer
No. The output contract is incompatible. Roll back the serving contract and any affected downstream components together, or add a tested adapter that converts the old output safely.