Sub topic 2
Choose the smallest safe rollback scope
A rollback scope is the set of components you revert when a model fails in production. The smallest safe scope reverts only what changed. Reverting more adds time and risk. Reverting less can leave the fault in place.
This chapter assumes you use version control for releases, can read service dashboards, and know that a model artifact is a serialized file of weights and config.
Choose the smallest safe rollback scope
Compare the failing release with the known-good release. Check the model artifact, the feature schema, the preprocessing code, and the dependency lock file.
| Changed component | Smallest safe scope |
|---|---|
| Model artifact only | Model rollback |
| Model and feature schema | Model and schema rollback together |
| Serving code or dependencies | Full application rollback |
Verify artifact identity, provenance, and integrity
Confirm that the artifact you restore is the exact file that passed validation. Compare its SHA-256 digest with the digest recorded at validation time. Provenance records where the artifact came from: the training run, the commit, and the approver.
import hashlib
import sys
from pathlib import Path
def sha256_of(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as f:
for chunk in iter(lambda: f.read(1 << 20), b""):
digest.update(chunk)
return "sha256:" + digest.hexdigest()
def verify_artifact(path: Path, expected_digest: str) -> None:
actual = sha256_of(path)
if actual != expected_digest:
raise SystemExit(f"Digest mismatch for {path}: {actual} != {expected_digest}")
print(f"OK: {path} matches {expected_digest}")
if __name__ == "__main__":
verify_artifact(Path(sys.argv[1]), sys.argv[2])Run it as python verify.py model.bin sha256:<digest>.
Check schema, code, dependency, and state compatibility
An older model may fail on a newer schema, library, or feature order. Check that the target model accepts the current input schema, that the serving code version supports it, and that the dependency versions match the lock file from the known-good release. If the service stores state, such as cached predictions or feature stores written by the new model, check that the old model can read it.
Prepare a reversible rollback plan
Write the plan before you start. Record the target version, the expected digest, the traffic steps, and the validation thresholds. A plan like this makes the change auditable and repeatable.
rollback:
target_version: "2026.03.08"
expected_artifact_sha256: "sha256:bbb"
traffic_steps:
- percent: 10
hold_minutes: 10
- percent: 100
validation:
max_error_rate: 0.03
max_p95_latency_ms: 250Control traffic during the change
Shift traffic in steps rather than all at once. Hold at each step long enough to see the error rate and latency. If a step breaks the thresholds, stop and send traffic back to the current release.
Exercise
Your release changed both the model artifact and the feature schema. Which rollback scope do you choose, and why?
Show answer
Roll back the model and the schema together. The known-good model expects the old schema, so restoring only the model would feed it inputs it cannot read.