Sub topic 6
Choose the Smallest Safe Rollback Scope
Assume you understand basic model deployment, production monitoring, version control, and APIs. This chapter focuses on choosing what to restore when a production model causes a problem. The goal is to reduce harm without changing healthy parts of the system.
A rollback scope is the set of deployed components you return to an earlier version. A model rollback changes only the model artifact. A service rollback changes the application code that loads or serves the model. A full rollback can also include preprocessing, schemas, dependencies, configuration, and infrastructure.
Why scope matters
A large rollback may remove the immediate failure, but it can also restore unrelated bugs or interrupt healthy traffic. A small rollback is easier to review and reverse. However, a model cannot be rolled back safely by itself if newer code or data schemas cannot use the older model.
Choose the smallest scope that restores compatibility and removes the cause of the incident.
| Observed failure | Likely smallest safe scope |
|---|---|
| New model has a quality regression, but inputs and serving code are unchanged | Model artifact |
| Model expects an incompatible feature schema | Model and preprocessing or schema package |
| New model-serving code changes request handling incorrectly | Model-serving service release |
| A shared dependency breaks several services | Application release or dependency set |
| Infrastructure or deployment configuration routes requests incorrectly | Configuration or infrastructure change |
Trace the failure before choosing
Start with evidence rather than the component that changed most recently.
- Compare the failing release with the last known-good release.
- Check whether the input schema, feature transformations, and output contract changed.
- Check service logs, latency, resource use, and model-quality metrics.
- Identify which traffic is affected: a region, tenant, endpoint, model variant, or all production traffic.
- Test the smallest candidate rollback against a representative request set.
For example, suppose a fraud model's false-negative rate increases after a model-only deployment. The preprocessing version, serving code, and output schema are unchanged. Rolling back only the model artifact limits the change to the likely cause.
If the old model requires a feature that the current preprocessing code no longer produces, a model-only rollback may fail or silently produce invalid predictions. Roll back the compatible model and preprocessing bundle instead.
Use a scope decision
The following simple policy makes the reasoning explicit:
def choose_scope(
model_regressed,
schema_changed,
serving_code_regressed,
shared_dependency_failed,
):
if shared_dependency_failed:
return "application and dependency set"
if serving_code_regressed:
return "model-serving service release"
if schema_changed:
return "model and preprocessing bundle"
if model_regressed:
return "model artifact"
return "investigate before rollback"
print(
choose_scope(
model_regressed=True,
schema_changed=False,
serving_code_regressed=False,
shared_dependency_failed=False,
)
)This policy does not replace investigation. It prevents a model-quality alert from automatically triggering a full application rollback.
Limit exposure while testing
Even when the chosen scope is small, start with limited traffic. Send the candidate release to a canary, a small percentage of requests, or an isolated tenant. Compare error rate, latency, prediction distributions, and business metrics with the current release.
Record the chosen scope, rejected alternatives, evidence, owner, and reversal steps. This record makes the decision auditable and helps the next operator act quickly.
Exercise
A new model increases prediction errors, but its input schema, preprocessing code, serving image, and dependencies match the previous release. What is the smallest safe rollback scope, and how should you expose it?
Show answer
Roll back the model artifact only, verify its digest, and first send it to a canary or limited traffic segment. Expand traffic after quality, service, and business metrics return to acceptable levels.