Sub topic 4
Signals that show a model version is unhealthy
This chapter assumes you can read basic Python and PromQL-style metric names. It also assumes you know what a served model endpoint is and what accuracy, latency, and error rate mean. The previous chapters covered versioned artifacts, the registry, and the deployment pointer. This chapter covers the first half of the decision to roll back: seeing that the version now serving traffic is bad. The next chapter turns these signals into explicit triggers and thresholds.
Why one dashboard is not enough
A model service can fail in two different ways. The first is an ordinary software failure: the endpoint returns 500 errors, times out, or runs out of memory. Standard service monitoring catches this quickly.
The second is a silent model failure. The endpoint returns HTTP 200 with a well-formed JSON body, and the prediction is wrong. A model that scores every transaction as "not fraud" is healthy by every infrastructure metric. Silent failures are common after a release because a new version can differ in preprocessing, feature handling, or training data in ways that do not crash anything.
So you need signals from several layers, each answering a different question.
| Layer | Question it answers | Example signals | Speed of feedback |
|---|---|---|---|
| Service health | Is the endpoint working? | Error rate, p95/p99 latency, timeouts, restarts, memory | Seconds to minutes |
| Input data | Is the model receiving what it expects? | Schema violations, null rate, out-of-range values, drift scores | Minutes to hours |
| Predictions | Is the model behaving differently? | Score distribution, predicted class share, confidence | Minutes to hours |
| Model quality | Is the model right? | Accuracy, precision, recall, calibration, computed from true labels | Hours to weeks |
| Business outcome | Is the product better or worse? | Conversion, chargeback rate, manual-review volume | Days to weeks |
Fast layers detect problems early but only imply a model problem. Slow layers confirm it but arrive late. A rollback decision usually combines a fast signal with a plausible link to the new version.
Tag every signal with the model version
The most important monitoring decision for rollback is to record the model version on every metric, log line, and prediction record. Without it you can see that the error rate rose at 14:05, but you cannot tell whether the release caused it. With it you can compare version 7 against version 6 over the same minutes, which removes traffic spikes and time-of-day effects from the comparison.
The example below uses the prometheus_client library to label request counts and latency by version. The model itself is a stand-in.
import random
import time
from prometheus_client import CollectorRegistry, Counter, Histogram, generate_latest
registry = CollectorRegistry()
REQUESTS = Counter(
"model_requests_total",
"Prediction requests by model version and outcome",
["model_version", "outcome"],
registry=registry,
)
LATENCY = Histogram(
"model_latency_seconds",
"Prediction latency by model version",
["model_version"],
buckets=(0.01, 0.05, 0.1, 0.25, 0.5, 1.0),
registry=registry,
)
def fake_model(features):
time.sleep(random.uniform(0.001, 0.01))
if random.random() < 0.05:
raise ValueError("bad input")
return random.random()
def predict(features, model_version):
start = time.perf_counter()
try:
score = fake_model(features)
REQUESTS.labels(model_version, "ok").inc()
return score
except Exception:
REQUESTS.labels(model_version, "error").inc()
raise
finally:
LATENCY.labels(model_version).observe(time.perf_counter() - start)
for i in range(200):
version = "6" if i % 2 == 0 else "7"
try:
predict({"amount": 10.0}, version)
except ValueError:
pass
for line in generate_latest(registry).decode().splitlines():
if line.startswith("model_requests_total{"):
print(line)Keep version labels to a small set of values. A label like model_version has a handful of values at any time, which is fine. Putting a request ID or a user ID in a label creates millions of time series and can overload your metrics system.
During a canary or blue-green release, both versions run at once, so the label also lets you compare them directly. When only one version serves traffic, the label lets you compare the current version against the numbers from before the release.
Service health signals
These are the signals you already know from other services. For models, watch the following.
- Error rate. Count 5xx responses, but also count application-level failures such as a model that returns a null prediction or a validation error. A model that fails open (returns a default score when it errors) hides failures unless you count the fallbacks.
- Latency percentiles. Use p95 and p99, not the mean. A new version with a larger model or slower preprocessing often shows up first in the tail.
- Saturation. CPU, GPU utilization, memory, and queue depth. A memory leak in a new version appears as a steady climb followed by restarts.
- Restarts and readiness failures. On Kubernetes,
CrashLoopBackOffandOOMKilledpod states point to a version that cannot run under the resource limits. - Cold-start time. A version that loads slowly can fail health checks during autoscaling even if it is fine in steady state.
Input data signals
A model is only valid for the kind of inputs it was trained on. Input signals tell you whether the version is being asked to work outside that range. They are also the right place to catch preprocessing mismatches, where the new version expects a feature to be scaled or encoded differently from what the serving pipeline sends.
Useful checks include:
- Missing-value rate per feature compared with the training data.
- Values outside the minimum and maximum seen in training.
- Unseen categories in categorical features.
- Type or schema changes, such as a numeric field arriving as a string.
- A shift in the distribution of each feature, measured with a drift statistic.
One common drift statistic is the Population Stability Index (PSI). It compares the share of values in each bin between a reference sample, such as the training data, and a recent window of live data. The code below bins by the reference quantiles.
import numpy as np
def psi(reference, live, bins=10):
"""Population Stability Index between two 1-D samples."""
edges = np.quantile(reference, np.linspace(0, 1, bins + 1))
edges[0], edges[-1] = -np.inf, np.inf
ref_share = np.histogram(reference, edges)[0] / len(reference)
live_share = np.histogram(live, edges)[0] / len(live)
ref_share = np.clip(ref_share, 1e-6, None)
live_share = np.clip(live_share, 1e-6, None)
return float(np.sum((live_share - ref_share) * np.log(live_share / ref_share)))
rng = np.random.default_rng(0)
reference = rng.normal(loc=0.0, scale=1.0, size=10_000)
same = rng.normal(loc=0.0, scale=1.0, size=2_000)
shifted = rng.normal(loc=0.8, scale=1.0, size=2_000)
print("PSI, same distribution: ", round(psi(reference, same), 4))
print("PSI, shifted distribution:", round(psi(reference, shifted), 4))A frequently quoted rule of thumb reads PSI below 0.1 as stable, 0.1 to 0.25 as worth watching, and above 0.25 as a major shift. Treat these numbers as a starting point and tune them on your own data.
Prediction signals
Prediction signals need no labels, so they arrive quickly. They work by comparing what the new version outputs with what the previous version output on similar traffic.
- Score distribution. If a fraud model's average score drops from 0.12 to 0.02 overnight, something changed, even if you cannot yet say what.
- Predicted class share. A classifier that suddenly predicts one class 99% of the time is almost always broken.
- Confidence or entropy. A sharp rise in low-confidence predictions suggests the model is seeing unfamiliar inputs.
- Constant or null outputs. Count identical outputs and missing outputs. These often come from a serialization or feature-order bug.
- Disagreement with the previous version. If you run the old version in shadow mode, where it receives a copy of traffic but its answers are not used, you can measure how often the two versions disagree. A high disagreement rate is a useful alarm for a release you expected to be a small change.
These signals are strong evidence of a change but weak evidence of a worse model. A new version is supposed to produce different predictions. Use them as a prompt to check the model-quality signals, and as a trigger on their own only for obviously degenerate behavior such as constant outputs.
Model quality signals
Accuracy, precision, recall, AUC, and calibration need ground truth labels, which in production usually arrive late. A loan default label arrives months later. A fraud label arrives when a customer disputes a charge. This delay creates two practical problems.
- The signal lags the release. By the time labels confirm that version 7 is worse, it may have served traffic for days. Rolling back then is still correct, but the damage is already done.
- Labels can be biased. If the model's decision determines whether you observe a label (you only learn the outcome for approved loans), the labelled sample is not representative.
To shorten the delay, use proxy labels. These are quicker events that correlate with the true outcome. Examples include a user rejecting a recommendation, an analyst overturning a flag, or a chargeback filed within 24 hours. Document each proxy's known weakness so that nobody treats it as ground truth.
Calibration deserves its own check. A model can keep the same ranking quality (AUC) while its predicted probabilities become unreliable. If downstream systems apply a fixed threshold, such as "block if score > 0.8", a calibration shift changes the number of blocked requests without any change in AUC.
Business and downstream signals
Consumers of the model feel problems that model metrics miss. Track the rate of manual reviews, customer complaints, conversion, and the volume of requests that fall back to rules. Downstream teams are often the first to notice that something is wrong, so give them a way to report it that reaches the on-call engineer.
Baselines, windows, and noise
A signal is only useful when you know what normal looks like. Three practices make the comparison fair.
- Compare against a baseline from the same period. The best baseline is the previous version serving concurrent traffic, such as the stable pool during a canary. The next best is the same hour and weekday in previous weeks, which accounts for daily and weekly cycles.
- Wait for enough data. A canary taking 1% of 200 requests per minute sees about two requests per minute. An error rate computed from ten requests swings wildly. Set a minimum sample size before any comparison counts.
- Choose the window to match the signal. Error rates can use a window of 5 minutes. A drift statistic needs thousands of rows. Accuracy may need a week. A window too short produces false alarms, and one too long delays detection.
Other edge cases to plan for:
- Seasonality and campaigns. A marketing event changes the input mix for a day. Annotate known events on dashboards.
- Upstream changes. A feature pipeline change can look exactly like a bad model release. Record deploy events for the feature pipeline and the model on the same timeline.
- Missing metrics. If a version stops reporting metrics, treat silence as a signal. A crashed exporter and a healthy quiet service look the same unless you alert on absent data.
- Metric bugs in the new version. A release that renames a label or metric can make a dashboard look healthy because the old series vanished. Check that the new version's series exist before trusting a flat line.
Putting the signals to work
For each model, write down a short signal inventory before release. It names the signals, the baseline each is compared with, the window, and the owner who looks at it. A minimal version has one or two signals per layer from the table above.
Then, during a release, watch in order of speed: service health first, then input and prediction signals, then quality as labels arrive. If a fast signal moves and a plausible explanation points to the new version, you have the evidence the next chapter turns into a rollback trigger.
Exercise
A new fraud model version 7 has been live for two hours. Error rate and p95 latency match version 6. The average predicted fraud score dropped from 0.12 to 0.02, and confirmed-fraud labels will not arrive for about two weeks. Which signals would you check next, and would you roll back now?
Show answer
Check input data signals first for a preprocessing or schema mismatch, such as nulls, scaling changes, or reordered features. Then compare the score distribution and predicted class share of version 7 against version 6 on the same traffic, ideally with version 6 in shadow mode. Look at proxy labels such as analyst overturns or 24-hour chargebacks. A tenfold drop in average score with healthy service metrics is a typical silent failure. If the input checks show a mismatch, or the shadow comparison shows version 7 missing cases version 6 flags, roll back now rather than wait two weeks for ground truth. If the inputs are clean and the shift matches a known change in the training data, keep watching with proxy labels.
Exercise
Why should metrics carry a model_version label, and what is the risk of using a request ID as a label?
Show answer
The version label lets you compare versions over the same time period, which separates the effect of the release from traffic spikes and daily cycles. A request ID has a new value for each request, so it creates a new time series each time, which grows storage and query cost without limit and can overload the metrics system.