Sub topic 1
Why Releasing a New Model Is Different from Releasing Code
A new model version can pass every test, deploy cleanly, and still make your product worse. This chapter explains why model releases carry risks that ordinary code releases do not, and why that justifies the staged rollout techniques the rest of this tutorial covers: shadow, canary, and A/B.
Prerequisites
This chapter assumes you have:
- A basic understanding of serving a model behind an HTTP or RPC endpoint.
- Familiarity with common model metrics such as accuracy, precision, recall, and latency.
- Basic probability and statistics, such as proportions and averages.
- Comfort reading short Python and YAML snippets.
You do not need to know Kubernetes or a service mesh yet. Later chapters introduce traffic routing in detail.
Code releases fail loudly, model releases fail quietly
When you release ordinary code, a bug usually shows up as a visible failure. An exception is thrown, a request returns a 500, a test breaks, or a page renders wrong. Monitoring built around errors and latency catches most of these quickly.
A model release can fail in a different way. The service starts, accepts requests, returns well-formed responses within the latency budget, and logs no errors. Yet the predictions are worse. A fraud model might let more fraud through. A ranker might push down the items users actually want. Every system health check stays green.
The core difference is that the correctness of a model is statistical, not logical. A function either returns the right value for an input or it does not, and a unit test can say which. A model is right some fraction of the time, and the question "is the new version better?" can only be answered by looking at many predictions.
| Property | Typical code change | Model change |
|---|---|---|
| Failure signal | Exceptions, failed tests, error codes | Often none; outputs look valid |
| What "correct" means | Deterministic, testable per input | Statistical, measured over many inputs |
| Time to notice a problem | Seconds to minutes | Hours to weeks |
| Dependence on data | Low | High; behavior depends on training data and live inputs |
| Rollback reveals the cause | Usually | Not always; the world may have changed |
Sources of release risk
Several separate things can go wrong when you swap a model. It helps to keep them apart, because each one is caught by a different technique.
Serving risk
The new model may be larger, slower, or hungrier for memory. It may need a different library version, a different input schema, or a GPU the pool does not have. These failures look like code failures: timeouts, out-of-memory kills, and crashes. They are the easiest to detect, and they affect system metrics such as error rate and p95 latency.
Quality risk
The new model may be worse on the cases that matter, even if it scored better on a test set. It may regress for a subgroup, such as a region, a device type, or a new customer segment, while the overall average improves. A mean improvement can hide a loss for a small but important slice of traffic.
Data and feature risk
A model depends on its inputs, and the inputs in production can differ from the inputs in training. Common causes include:
- Training-serving skew: a feature is computed one way in the training pipeline and another way at serving time.
- A feature that is missing or stale in production but was always present in the training data.
- A different default value for nulls.
- Upstream schema changes that silently shift a value's meaning or units.
The model will still return a number. It will just be a number computed from the wrong input.
Business risk
A model can improve its own metric and still hurt the outcome the business cares about. A recommendation model with higher click-through might lower purchases. A pricing model with lower error might reduce margin. The model's metric is a proxy for the business outcome, and proxies can drift apart from the goal.
Feedback risk
Model outputs often influence future data. A recommender decides what users see, and what users see determines what they click, and clicks become training data. A new model can change the data distribution it will later be retrained on. This makes some errors self-reinforcing and harder to undo than a code bug.
Why you cannot just test your way out
Code has a strong safety net: unit tests, integration tests, and staging environments that behave much like production. For models, the equivalent of a test is an offline evaluation on a held-out dataset. The next chapter covers it in detail, but the short version is that it measures how the model performs on historical data, and production data is not historical data.
Three gaps make offline results an incomplete guide:
- The data moves. The held-out set was sampled from the past. Live traffic reflects today's users, products, and seasons.
- The inputs are not the same. Offline evaluation usually reads features from a clean batch pipeline. Production reads them from online stores, caches, and upstream services with their own delays and failures.
- The system is part of the loop. Offline, a model's predictions affect nothing. Live, they change what users do, which changes the outcome you are trying to measure.
For these reasons, "it scored better offline" is a reason to try the model in production. It is not proof that the model is safe or better.
A concrete example
Suppose a team replaces a fraud model with a new version. Offline, recall at a fixed false-positive rate rises from 0.81 to 0.86. The service passes load tests. The team deploys it to all traffic on a Friday afternoon.
Over the weekend, a payment partner begins sending a transaction field in cents instead of dollars for one region. The old model had learned to be somewhat insensitive to that field. The new model relies on it heavily. For that region, it flags a large share of legitimate payments as fraud.
Nothing crashes. Error rate is flat. Latency is unchanged. The first signal is a spike in support tickets on Monday, and by then thousands of customers have had payments declined.
A staged rollout would have changed this outcome in two ways. A shadow run would have shown the new model's scores diverging from the old model's for that region before any user saw them. A canary at 5% would have limited the harm to a small share of customers and given a guardrail metric, such as decline rate, a chance to trigger an automatic rollback.
What staged rollouts are for
Each rollout strategy reduces a different kind of uncertainty by controlling who is affected and what you can measure.
| Strategy | Who sees the new model's output | What it answers | Main risk it removes |
|---|---|---|---|
| Shadow | No one; output is logged only | Does it run, and how do its predictions compare with the stable model's on real inputs? | Serving and data risk, with zero user impact |
| Canary | A small, growing share of real users | Is it safe for users, at increasing exposure? | Blast radius of an unnoticed failure |
| A/B test | A randomized share, held for a planned duration | Does it improve a business outcome, and by how much? | Shipping a change that does not actually help |
These are not competing options. They answer different questions and are often combined: shadow first, then canary, then an A/B test for the final decision. The last chapters of this tutorial cover how to choose among them.
The diagram below shows the general shape of a staged release and where each strategy fits.
Design principles that follow from the risks
The differences above lead to a few working rules that the rest of the tutorial puts into practice.
- Make rollback cheap. Keep the stable model deployed and routable until the candidate is proven. Rolling back should be a routing change, not a redeploy.
- Limit exposure first, widen later. Start with no user impact (shadow), then a small share (canary), then larger shares as evidence builds.
- Log enough to compare versions. You cannot judge a candidate against the stable model unless both versions' predictions for the same request are recorded.
- Decide thresholds before you start. Write down which metrics gate promotion and what values trigger a rollback, before you see the results. Deciding afterward invites rationalizing a bad result.
- Measure more than the model's own metric. Watch system health, model quality, and business outcomes together.
Common mistakes
- Treating offline metric gains as a deployment decision rather than a hypothesis to test.
- Replacing the stable model in place, with no way to route traffic back quickly.
- Monitoring only error rate and latency.
- Judging an overall average and missing a regression in a subgroup.
- Choosing success criteria after looking at the results.
- Ignoring that the model's outputs can change the data it will see next.
Summary
Code releases mostly risk visible breakage that tests and error monitors can catch. Model releases add quiet risks: quality that is only statistical, inputs that differ from training, business outcomes that diverge from model metrics, and feedback loops. Offline evaluation is necessary, but it cannot cover these. Shadow, canary, and A/B rollouts exist to expose the model to production reality in controlled steps, each answering a different question while limiting user harm.
Exercise
A team's new recommendation model beats the current one on every offline metric. It passes load tests, and after deployment to 100% of traffic, error rate and latency are unchanged. Two weeks later, revenue per user has dropped. Name two reasons this could happen despite the offline results and the healthy system metrics, and name one rollout step that would have caught it earlier.
Show answer
Possible reasons: (1) the offline metric, such as predicted click accuracy, was a proxy that did not track revenue, so a model can win offline and lower purchases; (2) live inputs or user behavior differed from the historical held-out data, for example through training-serving skew or a changed user mix; (3) the model's own recommendations altered what users did, which offline evaluation cannot capture. Error rate and latency only detect serving failures, so they stayed green. An A/B test measuring revenue per user against the stable model, or a canary with a business guardrail metric that could trigger rollback, would have exposed the drop while only a share of users was affected.
Exercise
Why does a model rollback need the stable version to stay deployed and routable during the rollout, and what does that make a rollback?
Show answer
If the stable model stays deployed, restoring it only requires changing the traffic routing back to it, so a rollback is a fast configuration change and not a rebuild or redeploy. If the stable version were removed, rollback would mean redeploying it under pressure while users are affected.