Monitoring, drift, and governance beyond LLM serving
Lesson 11 taught production for GPU serving: queue depth, KV utilization, p99 TTFT/TPOT, rollback, and cost. General ML adds another class of incidents: the service is fast and healthy, but the data changed, features went stale, calibration drifted, the ANN index aged, or one segment regressed. These are silent failures unless you monitor the material flow, not only the API.
0 · The incident thinking loop
When a production ML metric moves, do not jump straight to retraining. Retraining before diagnosis can hide the bug. Work linearly:
- Detect: which contract moved: schema, freshness, feature values, scores, labels, slice metric, index, latency, or cost?
- Localize: did it move for all traffic or one segment, feature owner, model version, route, region, or device?
- Compare: replay the same examples against the previous model/feature/index bundle.
- Stabilize: rollback, use a feature fallback, rebuild an index, adjust a threshold, or shed a risky route.
- Learn: retrain only after you know whether the problem is data drift, concept drift, calibration drift, or a broken pipeline.
1 · The monitor stack
| Layer | Leading signal | Incident it predicts |
|---|---|---|
| Data quality | Schema violations, null spikes, enum drift | Feature computation or upstream logging broke |
| Freshness | Max feature age, stream lag, index age | Decisions made from stale world state |
| Train-serve parity | Online/offline feature diff on shadow examples | Model sees different inputs in prod than training |
| Prediction drift | Score distribution shift, entropy, top-K churn | Input distribution or model behavior changed |
| Calibration drift | Reliability curve moves after labels mature | Thresholds and expected values are wrong |
| Outcome drift | Delayed labels, conversion, complaints, chargebacks | True product quality changed |
| Slice health | Metrics by cohort, region, language, device | Aggregate hides subgroup regression |
2 · Drift comes in four different species
"Drift" is too vague to debug. Name the species before picking a response.
| Drift type | What moved | Example | Response |
|---|---|---|---|
| Data drift | P(x) | More mobile users, new merchant category | Check feature distributions; maybe retrain |
| Concept drift | P(y|x) | Fraudsters change tactics | Fresh labels, faster retrain, new features |
| Calibration drift | Score-to-probability mapping | 0.8 risk now means 0.5 actual rate | Recalibrate or adjust thresholds |
| Policy drift | The system changed its own data | Ranker overexposes one content type | Holdout/exploration traffic, bias correction |
2.5 · Drift statistics — measure movement before naming a cause
Once you know which distribution might have moved, use a statistic that matches the object. For binned features and score distributions, three common first-pass monitors are:
KS = max_x |F_cur(x) − F_base(x)|
KL(cur || base) = Σ_i cur_i · ln(cur_i / base_i)
Worked example: baseline bins (.25,.25,.25,.25), current bins (.40,.30,.20,.10). Then PSI≈.228, KS=.20, and KL≈.106 nats. Read that as meaningful movement, not automatic model failure.
3 · Train-serve skew monitor
The most direct skew test is to log online requests, replay the same request through the offline feature pipeline, and diff the feature vectors.
For numerical features, use tolerances; for categorical and embedding features, version and exact-match semantics matter. Alert on both global skew and skew by feature owner. A single hot feature drifting can damage every model that consumes it.
| Skew symptom | Likely cause | Fix |
|---|---|---|
| Online value missing, offline present | Online store lag or TTL expiry | Freshness alert, backfill, fallback policy |
| Aggregate off by a window | Event-time vs processing-time mismatch | Shared window definition and watermark |
| Embedding dimensions/version differ | Embedding model and index not upgraded together | Versioned embedding/index bundle |
| String/category mismatch | Different normalization code | Single feature definition, parity tests |
4 · Retrieval/index monitoring
For search/RAG/recsys, the index is part of the model. Monitor it like a model artifact.
| Metric | Meaning | Bad day |
|---|---|---|
| Index freshness | Age of newest included document/item/user embedding | New content invisible; deleted content still retrievable |
| Recall@K on probe set | ANN approximation quality | Latency optimization silently drops relevant items |
| Lookup p99 | Serving tail for retrieval stage | Ranking SLO breaks before model score runs |
| Filter/ACL miss rate | Permissions and business constraints | Unauthorized or unavailable items appear |
| Embedding version mix | Whether index and query encoder match | Semantic space mismatch kills recall |
Related deep dives: real-time recommendation, deployment and serving, and large-scale optimization.
5 · Governance is operational, not decorative
Governance means the system can enforce constraints automatically. It is not a PDF saying "be careful."
| Constraint | Operational enforcement | Failure if informal |
|---|---|---|
| Privacy / retention | PII redaction, TTL, deletion propagation, consent flags | Training on data user opted out of |
| Fairness / slices | Predeclared slice guardrails and release blocks | Aggregate win harms subgroup |
| Explainability / audit | Store reason codes, features, model version, threshold | Cannot explain adverse action |
| Rollback | Versioned model + feature + threshold bundle | Weights revert but feature contract stays broken |
| Cost | $/prediction and capacity dashboards | Traffic grows faster than unit economics |
What carries forward
- Monitor contracts, not only uptime. Fast wrong decisions are still incidents.
- Name the drift species. Data, concept, calibration, and policy drift require different responses.
- Train-serve skew is measurable. Replay online examples through offline features and diff them.
- Indexes are model artifacts. Version, monitor, rebuild, and rollback them with the model.
- Governance must be enforceable. Privacy, fairness, explainability, rollback, and cost need system hooks.