ML Systems: Technical Debt & Monitoring
Feedback loops, testing and monitoring models in the wild.
In a production system the model is a small box, surrounded by data pipelines, configuration, serving code and monitoring, and most failures happen outside the box. This lesson treats the whole system as an object of study: the forms of hidden technical debt, a rubric for testing ML systems, data validation at scale, change detection with a provable false-alarm rate, and the theory of feedback loops, in which a model's predictions reshape the data it will later learn from.
What you’ll learn
- Identify the ML-specific forms of technical debt, such as entanglement, correction cascades, undeclared consumers, data dependencies and feedback loops, and their mitigations.
- Apply the ML Test Score rubric and schema-based data validation, and explain why significance tests make poor alarms at production scale.
- Derive the CUSUM change detector, prove that its average run length to a false alarm is at least , and estimate its detection delay from a KL divergence.
- Formalize performative prediction, prove that repeated retraining converges to a performatively stable point when , and bound the distance between stable and optimal points.
The model is the small box
Sculley et al. (2015) drew a real-world ML system as a large diagram in which the ML code is a small black box in the middle, and the infrastructure around it, from data collection and feature extraction to configuration, resource management and monitoring, is vast and complex. Their argument, in the language of software engineering, is that ML makes it easy to incur technical debt: quick wins whose maintenance cost compounds silently. Many of the debts have no analogue in ordinary software, because the system's behavior is specified by data rather than by code.
| Debt | What goes wrong | Mitigation |
|---|---|---|
| Entanglement | "Changing Anything Changes Everything" (CACE): shifting one feature's distribution, adding or removing a feature, or changing a hyperparameter re-weights all the others | isolate sub-models where the problem decomposes; monitor prediction behavior slice by slice |
| Correction cascades | a model learns a small correction on top of for a related problem; improving now breaks | add features to that distinguish the cases, or build the new model directly |
| Undeclared consumers | other systems silently read a model's outputs, so changing the model changes them, possibly closing a hidden loop | access controls and service agreements on model outputs |
| Unstable and underutilized data dependencies | input signals produced by other teams change without notice; legacy, bundled, barely useful ("epsilon") and redundant correlated features add risk for little gain | versioned copies of input signals; regular leave-one-feature-out audits |
| Feedback loops | direct: a model influences the selection of its own future training data; hidden: two systems influence each other through the world | randomization, holding out data from the model's influence, bandit methods |
| Glue code and pipeline jungles | most code converts data in and out of general-purpose packages; preparation pipelines grow by accretion | design data collection and features holistically; wrap packages in common APIs |
| Configuration debt; fixed thresholds | more lines of configuration than code, rarely tested; decision thresholds tuned once on data that no longer exist | review and test configuration like code; learn thresholds on held-out data and re-learn them |
A team removes a feature whose learned weight was close to zero, retrains, and finds that the model's behavior changed a lot for one customer segment. What is the most likely explanation?
- A bug: a near-zero weight means the feature had no influence, so nothing should change
- Entanglement: a correlated feature had absorbed part of the effect, and removing one re-weighted the others, especially where they disagree
- Label shift between the old and new training sets
- The retrained model overfit because it has fewer features
Show the answer
B. Entanglement: a correlated feature had absorbed part of the effect, and removing one re-weighted the others, especially where they disagree
Weights of correlated features are jointly determined; a small weight does not mean small influence on the fit as a whole. Removing a feature changes the optimal weights of all the others, and the change shows up most where the correlated features carry different information, for example in a particular segment. That is CACE.
Testing and validating ML systems
The ML Test Score (Breck, Cai, Nielsen, Salib & Sculley, 2017) turns production readiness into a rubric of 28 tests in four sections of seven: data (feature expectations are captured in a schema; every feature is beneficial and worth its cost; feature code is tested), model (offline proxy metrics correlate with live ones; the impact of staleness is known; a simpler model is not better), infrastructure (training is reproducible; the full pipeline is integration-tested; models are canaried and can be rolled back quickly) and monitoring (data invariants hold in training and serving; training and serving compute the same features; models are not too stale; no regressions in prediction quality). A test earns half a point if run manually with documented results and a full point if automated and run repeatedly; each section's points are summed, and the final score is the minimum over the four sections, so neglecting any one area caps the whole.
Data validation (Breck, Polyzotis, Roy, Whang & Zinkevich, 2019) treats data errors like software errors. Each batch of training data is checked against a schema that encodes expected types, domains, presence and value constraints, and the schema evolves through suggested edits that a person approves. Serving data are compared continuously with training data for three kinds of training–serving skew:
- Feature skew: a feature takes different values for the same example in training and in serving, typically because two code paths compute it.
- Distribution skew: the distribution of a feature differs, for example because of a flawed sampling scheme.
- Scoring/serving skew: only some scored examples are served (ten videos shown out of a hundred scored), so unshown items never acquire labels, an implicit feedback loop.
For the distribution comparisons they deliberately avoided significance tests. In their experiment, replacing 10,000 of 100 million standard normal draws with draws from a wider normal, a 0.01% contamination no one would care about, made a χ² test reject at the 1% level in 7 of 10 trials. They used instead an interpretable distance with a threshold teams can set directly, the distance between categorical distributions.
Testing extends to research practice. The NeurIPS 2019 reproducibility program (Pineau et al., 2021) combined a code submission policy, a community-wide reproducibility challenge and a reproducibility checklist that authors answered at submission and again at the camera-ready stage, with questions such as whether the paper describes how experiments were run and defines the measures used to report results. It is the research counterpart of the ML Test Score: a list of mechanical checks that catches omissions before they become irreproducible claims.
Change detection with a guaranteed false-alarm rate
Monitoring is sequential: data arrive one observation (or batch) at a time, and a change can happen at an unknown time . Testing afresh each day ignores the sequence; the classical answer is Page's (1954) cumulative-sum procedure. Suppose observations are i.i.d. with density before the change and after. The monitored quantity can be anything with a stable reference distribution: a feature's mean, the fraction of positive predictions, or once labels arrive the error indicator.
Each observation contributes a log-likelihood ratio, negative on average before the change and positive after it:
CUSUM keeps the log-likelihood ratio of the most likely change point so far, clipped at zero, and alarms when it reaches a threshold :
False alarms. Between returns to zero, runs a one-sided sequential test from 0. Under , is a nonnegative martingale with mean 1, so by Ville's maximal inequality an excursion reaches with probability at most . Excursions are independent and each lasts at least one step, so the number of them before the first alarm is geometric with mean at least :
Delay. After the change, climbs at an average rate of per observation. From the worst start , Wald's identity says the unclipped sum needs observations to reach , and the resets at zero can only shorten that, so to first order the delay is . Lorden (1971) proved that no procedure whose mean time to false alarm is at least can have a worst-case delay asymptotically smaller than , so CUSUM with is asymptotically optimal; Moustakides (1986) proved it exactly optimal for Lorden's criterion.
A standardized monitoring statistic is while all is well and after a fault. You set , so false alarms come at most once per 10,000 observations on average. About how many observations after the fault until CUSUM alarms?
Show the answer
74 observations
, so the delay is about observations (a simulation gives about 70: the resets at zero save a little more than the overshoot past costs). Here : CUSUM is a running sum of the observations minus half the shift, reset at zero. Halving the shift quadruples the delay; tightening the false-alarm rate tenfold adds only observations.
In practice is unknown, so one designs for the smallest shift worth detecting, or maximizes over a family of alternatives (generalized likelihood ratio). Monitoring hundreds of statistics multiplies false alarms by their number unless thresholds are raised accordingly, about more for independent streams at the same overall rate. Labels often arrive late; until they do, prediction-based statistics, including the label-shift estimate from the flagged rate, are the earliest signals available.
Feedback loops: when the model writes its own data
A direct feedback loop arises when a model influences the selection of its own future training data. Sculley et al. note that the principled treatment is a bandit algorithm, which accounts for the fact that you observe outcomes only for the actions you take, and that partial randomization is a practical mitigation. The simplest case shows what goes wrong without it.
The loop can also run through people. Jiang, Chiappa, Lattimore, György & Kohli (2019) modeled a user whose interest in an item grows when it is shown and clicked and shrinks when shown and ignored, and gave conditions under which repeated recommendation drives interest to degenerate, diverging to : echo chambers as a property of the dynamics. In their analysis and simulations, random exploration and a growing pool of candidate items slow the degeneration. Among the policies they compared, oracles that know the user's interests and exploit them fully degenerated fastest, Thompson sampling and UCB more slowly, and a purely random recommender slowest: the better a system exploits, the faster it narrows what the user is exposed to.
When the loop runs through strategic people who change their features to obtain a better decision, the setting is strategic classification (Hardt, Megiddo, Papadimitriou & Wootters, 2016). The framework below contains strategic classification as a special case; the interest dynamics above go beyond it, because there the data depend on the whole history of recommendations, not only on the model currently deployed.
Performative prediction
Write , minimized by , and for , minimized by ; let . Strong convexity of and optimality of give:
The function is -Lipschitz by joint smoothness. By Kantorovich–Rubinstein duality its expectations under the two distributions differ by at most , and under it is nonnegative by first-order optimality of for :
Combine the two inequalities and divide by . For the map is a contraction, and the Banach fixed-point theorem gives a unique fixed point, which is exactly a stable point, and geometric convergence:
A model's loss is -strongly convex and -jointly smooth. Up to what sensitivity of the world's response does the theorem guarantee that retraining converges?
Show the answer
0.25
The condition is . At the contraction factor is , so each retraining cuts the distance to the stable point by 60% and ten retrainings by a factor of about . A ridge penalty raises both constants by , so grows toward 1 and the safe range widens: in this theory, regularization makes retraining more stable.
Stability is not optimality. A stable point is a fixed point of retraining: it is optimal given the distribution it has caused, ignoring that a different model would cause a different distribution. The performative risk can even be concave under all the assumptions above (Perdomo et al., 2020), so minimizing it directly is hard in general, and the bound is what makes retraining a reasonable proxy when the world reacts weakly.
Key takeaways
- Most of an ML system is not the model. Entanglement (CACE), correction cascades, undeclared consumers, unstable data dependencies, feedback loops and configuration are ML-specific technical debt.
- The ML Test Score grades data, model, infrastructure and monitoring tests and takes the minimum; schema-based data validation catches feature, distribution and scoring/serving skew, with effect-size thresholds rather than p-values at scale.
- CUSUM, , has mean time to false alarm at least and delay about , which is asymptotically optimal (Lorden) and exactly optimal in Lorden's sense (Moustakides).
- A model that chooses which outcomes it sees can lock into its mistakes, like a greedy bandit; exploration and randomization keep the data informative.
- Performative prediction: with -strongly convex, -jointly smooth losses and an -sensitive world, retraining contracts at rate to a stable point within of the optimum; for it can fail.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A team scores its system with the ML Test Score: data 5, model 4.5, infrastructure 3, monitoring 1. What is its final score?
- 13.5
- 3.375
- 5
- 1
Show the answer
D. 1
The final score is the minimum over the four sections, so the neglected monitoring caps the whole at 1. The rule is deliberate: a system is only as production-ready as its weakest area.
You want CUSUM to raise a false alarm no more than once per 1,000 observations on average. What is the smallest threshold on the log-likelihood-ratio scale that the bound certifies?
Show the answer
C.
, so suffices. The threshold enters through its exponential, which is why tightening the false-alarm rate is cheap in delay: each tenfold reduction adds only observations of delay.
A drift monitor runs a χ² test on 50 million rows per day for each feature and alerts at . It alerts on most features every day, yet the model's accuracy is stable. What is the best fix?
- Lower the level to
- Alert on an interpretable effect size, such as the distance between category frequencies, with thresholds tied to what the model is sensitive to
- Sample 1,000 rows per day so the test loses power
- Stop monitoring inputs and wait for labels
Show the answer
B. Alert on an interpretable effect size, such as the distance between category frequencies, with thresholds tied to what the model is sensitive to
At this scale every real but trivial difference is significant; a stricter level only postpones the problem. An effect-size threshold asks whether the shift is big enough to matter, and keeps the full data.
Under the conditions of Perdomo et al.'s theorem, repeated retraining converges to . What can you say about its performative risk?
- It is the minimum possible: stable points are performative optima
- Nothing: stable points can be arbitrarily bad
- It is not necessarily optimal, but if the loss is -Lipschitz in , the stable point lies within of every performative optimum
- It equals the risk of the first deployed model
Show the answer
C. It is not necessarily optimal, but if the loss is -Lipschitz in , the stable point lies within of every performative optimum
A stable point is optimal for the distribution it induces, not across all the distributions other models would induce. Strong convexity and -sensitivity keep the two notions close: .
Further reading
- D. Sculley, G. Holt, D. Golovin, E. Davydov, T. Phillips, D. Ebner, V. Chaudhary, M. Young, J.-F. Crespo & D. Dennison, "Hidden technical debt in machine learning systems," Advances in Neural Information Processing Systems 28 (2015).
- E. Breck, S. Cai, E. Nielsen, M. Salib & D. Sculley, "The ML test score: a rubric for ML production readiness and technical debt reduction," IEEE International Conference on Big Data, 1123–1132 (2017).
- E. Breck, N. Polyzotis, S. Roy, S. E. Whang & M. Zinkevich, "Data validation for machine learning," Proceedings of Machine Learning and Systems 1 (2019).
- G. Lorden, "Procedures for reacting to a change in distribution," Annals of Mathematical Statistics 42(6), 1897–1908 (1971).
- J. C. Perdomo, T. Zrnic, C. Mendler-Dünner & M. Hardt, "Performative prediction," ICML (2020).