FullStack AI Hub
Studio
lesson depth
Mastery
not started · 0%

MLOps Lifecycle

How versioned artifacts evaluation promotion monitoring rollback and retirement make model changes governable.

Freshness: current•15 min read•Model Serving and MLOps

Key Learning Outcomes

  • ✓Version models prompts datasets and evaluations together
  • ✓Define promotion rollback and retirement controls
  • ✓Preserve lineage across deployments
Full Technical Reference Document

Mental model

A production AI or ML release is not a raw .safetensors weight file or system prompt string—it is an immutable, cryptographically addressed evidence bundle connecting base model weights/adapters, tokenizer and prompt templates, preprocessing feature code, training/evaluation dataset SHA digests, offline golden benchmark scores, safety sign-offs, serving container configuration, and a verified rollback path. MLOps governs the continuous closed loop across development, registry promotion via stage aliases, canary/shadow rollout, post-deploy drift & quality observability, deterministic rollback, and eventual retirement so no model change reaches customers without traceable lineage and fast recovery.

Log Training / Eval Run
Register Immutable Bundle & Signature
Pass Offline Quality & Safety Gates
Shift Champion Alias atomically
Canary Deploy + Monitor Drift
Verify Rollback or Retire Cleanly
Conceptual teaching model synthesized from:mlflow-model-registry,nist-ai-rmf

Theory

Mature MLOps teams strictly separate artifact identity (immutable versions: v14 / sha256:8f2a...) from deployment intent (mutable aliases: @challenger, @champion, @rollback-safe), never copying overwritten files cleanly onto models/latest.bin in object storage!

Lifecycle PhaseGoverned Artifacts & ContractsMandatory Promotion / Safety GateCommon Operational Risk Without Gate
Experiment & Lineage TrackingGit commit SHA, base model ID, prompt/parser template version, training & eval data hashReproducible run parameters & dependency lockfile (uv.lock / Docker digest)"It worked on Sarah's notebook last Tuesday" non-reproducible model drift
Registry & Alias PromotionImmutable version node + signature + eval scorecard JSON attached as artifactAutomated accuracy/latency/toxicity regression check (delta >= 0, p99 < budget)Mutating prod-model tag in-place destroys rollback history
Deployment & Progressive DeliveryExact container digest + hardware runtime (vLLM/TensorRT version) + feature schemaShadow mirror -> 5% canary -> full rollout with auto-abort alertsHidden tokenizer or quantization shifts crash structured JSON outputs in prod
Monitoring, Rollback & RetirementInput distribution drift, calibration shift, refusal rate, business KPIs, deprecation policyInstant alias revert (@champion -> v13) + verified N-1 schema backward compatibilitySilent accuracy rot ("data drift") or broken rollback hitting removed DB columns

Immutable Evidence Bundles, Shadow/Canary Verification, and Tested Rollbacks

In MLflow, Weights & Biases, or OCI artifact registries, registering a model version should attach all coupled inference dependencies (tokenizer vocab, preprocessing transforms, JSON output schema version, prompt bundle digest, and serving image tag) alongside quantitative scorecard tags validated against both slice-level offline metrics and guardrailed safety datasets. Before flipping production traffic onto a candidate @challenger, route dark production traffic (Shadow Deployment) or 1%–5% live traffic (Canary) comparing output schema validity, tail latency, and cost-per-task side-by-side against @champion—and practice rollbacks explicitly before retiring version N-1, ensuring feature stores and database tables remain backward-compatible throughout the bake window!

python
from dataclasses import dataclass
from typing import Mapping
​
@dataclass(frozen=True)
class ModelReleaseBundle:
model_name: str
version: str # Immutable registry ID (never "latest")
git_sha: str
dataset_digest: str
prompt_digest: str
eval_metrics: Mapping[str, float]
rollback_version: str
​
def verify_promotion_gates(
candidate: ModelReleaseBundle,
champion_metrics: Mapping[str, float],
) -> tuple[bool, list[str]]:
failures: list[str] = []
# 1. Require full provenance before promoting any artifact toward production
if not all([candidate.git_sha, candidate.dataset_digest, candidate.prompt_digest, candidate.rollback_version]):
failures.append("Incomplete provenance bundle or missing explicit rollback target")
​
# 2. Enforce non-regression on primary quality, safety, and tail latency SLAs
if candidate.eval_metrics.get("f1_macro", 0.0) < champion_metrics.get("f1_macro", 0.0):
failures.append("Quality gate failed: candidate f1_macro regressed below champion")
if candidate.eval_metrics.get("safety_violation_rate", 1.0) > 0.005:
failures.append("Safety gate failed: violation rate exceeds 0.5% threshold")
if candidate.eval_metrics.get("p99_latency_ms", 9999.0) > 450.0:
failures.append("Latency gate failed: p99 exceeds 450ms serving budget")
​
return (len(failures) == 0, failures)

Finally, schedule explicit Model Retirement: decommission unused endpoints cleanly, revoke orphaned API/KMS credentials tied to retired LoRAs or registries, archive audit records according to retention laws (NIST AI RMF), and prevent zombie unmonitored endpoints from accumulating security drift.

Alternatives and trade-offs

  • Dedicated Model Registry + CI/CD Promotion Aliases (MLflow Registry, OCI Artifacts, Vertex/SageMaker Registry): Enforces immutable lineage, RBAC approval workflows, and automated canary promotion hooks cleanly across multi-person teams; introduces registry operations, artifact storage lifecycle cleanup, and CI/CD glue scripts.
  • Git + Content-Addressed Object Store (S3 + DVC / Git SHA tags): Very lean for 2–4 engineer startups running a single model when deployments already track git_sha + immutable S3 prefixes cleanly without separate registry UIs—yet lacks out-of-the-box slice comparisons, runtime alias pointers, and governance audit logs as model variants multiply.
  • Direct API Provider Alias Pinning (model="gpt-4o-mini" Unpinned vs Exact Snapshot gpt-4o-mini-2024-07-18): Relying on vendor rolling aliases outsources MLOps completely, at the severe cost of unannounced vendor behavior/refusal/JSON formatting changes breaking production overnight; pin immutable snapshot dates and evaluate updates inside the same MLOps gate before switching aliases.

Failure modes and misconceptions

  1. Versioning Only Weights While Mutating Prompts, Tokenizers, or Preprocessing Separately: Re-deploying yesterday's weight file alongside today's changed normalization constants or edited system prompt silently produces different outputs—destroying reproducibility during incident postmortems. Bundle prompts, schemas, and preprocessing version digests together cleanly.
  2. Broken Rollbacks Because DB / Feature Schemas Dropped N-1 Columns: Promoting v15 and immediately migrating feature stores to drop a column required by v14 turns the emergency @champion -> v14 rollback switch into an instant crash! Keep feature and API schemas backward-compatible across active rollback retention windows (Expand-and-Contract).
  3. Monitoring Only Infrastructure Health (HTTP 200, CPU %, GPU VRAM): A model quantized aggressively or hit by upstream covariate drift happily returns HTTP 200 OK in 40 ms while hallucinating or dropping precision by 18%! Continuously track output confidence distributions, empty/malformed JSON rates, human feedback thumb-down ratios, and periodic labeled shadow audits.
  4. Overwriting Mutable Storage Paths (s3://models/prod/model.pt): Destroys atomic auditability, causes split-brain mixed loads across pods pulling mid-upload, and breaks instant revert capability. Always write content-addressed immutable paths and shift runtime aliases atomically.
Reflect before revealing the guide

Decision scenario

Your team ships a fine-tuned document classification + extraction pipeline serving 50,000 enterprise contracts daily, and suffered a silent accuracy regression last quarter after a prompt edit landed alongside stale tokenizer configs without an instant rollback option. Establish an MLflow Registry + CI/CD alias pipeline: require every registered release (ModelReleaseBundle) to bundle immutable model weights/adapter hash, prompt template SHA, tokenizer lock, dataset digest, and offline eval scorecard across hard edge-case slices; block promotion to @challenger automatically if macro_f1, schema compliance, or p99 tail latency regresses; validate @challenger via 48-hour dark shadow traffic + 5% canary rollout before shifting @champion atomically; enforce backward-compatible schema retention until N-1 retires; and continuously monitor input drift + human review agreement post-launch.

Learning outcomes

  • Define a production ML/AI release cleanly as an immutable evidence bundle connecting code, data, prompt, model, evals, and runtime image.
  • Separate immutable version identity cleanly from mutable deployment aliases (@challenger, @champion, @rollback-safe).
  • Design automated pre-promotion quality, safety, and latency gates followed by shadow/canary progressive rollout and verified N-1 rollbacks.
  • Distinguish infrastructure uptime monitoring from semantic drift, calibration shift, and model retirement hygiene.

Trade-offs

Formalizing end-to-end MLOps lineage, alias promotion gates, and post-deploy drift tracking dramatically lowers incident blast radius and satisfies audit compliance (NIST AI RMF), while adding CI pipeline duration, artifact storage retention discipline, and schema backward-compatibility constraints across active releases.

Prerequisites & Related Concepts (1)

Private notes

0 words
Included In Free Course
Free · Verifiable Credential

FS-101Model Serving and Inference

Understand inference engines memory scheduling batching routing scaling distributed execution lifecycle controls observability and economics.

19 concepts~23h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.