11 / 16 · Serving
Rolling out models
How to stage model exposure, plan an experiment and interpret stopping rules: original calculations for canaries, allocation, uncertainty, noninferiority and ranking comparisons.
On this page 12
A candidate preview model produces more accepted previews in a trial. That is useful only if the right users were compared, failed requests were still counted, the result was not selected from repeated looks, and the deployed bytes match the evaluated artifact. A rollout connects an engineering decision about exposure to a statistical decision about evidence.
We will use independently specified fictional counts and ranking lists. The accompanying standard-library program calculates planning approximations, intervals, an exact small stopping experiment and a population-mixture counterexample. These are teaching inputs, not results from BIASED users or an experiment run against a real service.
Define what the change can affect#
A model release includes feature state, model parameters, thresholds and serving code. Changing only the model file can still alter which requests reach a fallback, how long an answer takes and which future examples receive labels. A valid offline score cannot observe every consequence of that change.
Identify the release bundle and the intended decision. For our hypothetical preview service, the primary outcome is whether an eligible assigned user obtains an accepted preview within a fixed observation window. Define eligibility before assignment, fix how repeated requests are aggregated, and record the version actually served. Keep technical failures in the denominator when they prevent that user from succeeding.
Select guardrails separately: failure rate, latency, resource consumption and an agreed quality floor can stop exposure even when the primary outcome improves. Do not quietly replace a failed primary metric with whichever secondary measure looks best. A release owner needs an abort path and an identified compatible fallback before exposing real users.
Increase exposure when the next question is answerable#
The stages answer different questions. A local replay checks a known input contract. Shadow execution checks the candidate’s behaviour on permitted current inputs. A small live cohort exposes a bounded part of the service to actual consequences. A planned randomized comparison estimates an outcome difference. Wider rollout then tests capacity and continuing operation.
A successful stage permits the next bounded decision; it does not certify every later scale. A low-volume canary may never hit the concurrency that causes a queue to grow. A randomized comparison may pass for one population while a new region uses a different scanner. Record the reason for each increase, its observation period and who can stop it.
The Google SRE canary chapter describes partial exposure and evaluation as parts of the release process. Our examples use their own counts and service contract; no chapter application, failure injection, graph or rollout percentages are reproduced.
Shadow execution must suppress unintended actions#
A shadow candidate can read an approved copy of an input while the baseline response remains authoritative. Compare output contracts, disagreement rates and runtime resource use. Ensure candidate calls cannot charge an account, publish a document or overwrite the baseline’s data. Suppressing the displayed response is not enough if a downstream tool still performs an action.
Shadow traffic also consumes shared resources and may retain data. Bound its volume and retention, and observe whether it slows the service it is meant to test. The old system’s outcomes are not automatically labels for the candidate’s decisions: if the candidate would show another preview, the user’s reaction to that unseen preview is unknown.
Stop a canary for an operational reason#
Suppose a declared operational rule pauses exposure when more than 5% of 200 candidate save attempts fail. A constructed trace has 14 failures, so its 7% rate crosses that rule; the simultaneously specified baseline has two failures out of 200. This is a deliberately simple failure gate, not a power calculation or a calibrated hypothesis test.
Break down measurements by actual release identity. Combining a small failing candidate with a large healthy baseline can hide its failure rate. Check the fallback path as well: a candidate that silently routes every difficult request to the old service may look healthy while providing little evidence about its own operation.
Pausing does not require proving the entire cause. Preserve the permitted evidence, restore the known response path and investigate. Repeatedly restarting the same canary until it happens to pass converts the observation rule into another selection process. Record attempts and the material changes between them.
Plan the detectable change#
Sample size follows the unit, effect, variability and decision rule. A number of requests is not necessarily a number of independent users. A low-risk exposure fraction is not necessarily an efficient allocation for estimating a small difference. Plan both the operational risk and the statistical information needed.
Express the effect in outcome units#
For planning, stipulate a baseline success probability of 0.40 and a candidate probability of 0.44. The absolute effect is , or four percentage points; relative to 0.40 it is a 10% increase. Those are different scales. State which one the release decision uses before looking at the result.
Choose a difference worth acting on rather than a difference that is convenient to detect. If the computation is intended to save cost with almost unchanged quality, a non-inferiority decision may be appropriate; it requires a separately justified acceptable loss. Statistical significance cannot supply that product tradeoff.
Derive the variance for the chosen unit#
For independent binary outcomes, a sample proportion based on users has variance . Independence between arms lets the variances of their estimated means add. A planning simplification uses a common probability for both arms. With total size and candidate fraction ,
For a two-sided normal approximation with significance level 0.05 and target power 0.80, this gives the rough planning requirement
The fixture evaluates standard normal quantiles and rounds up. This common-variance approximation is a planning model, not an exact guarantee of 80% power for every Bernoulli design. Rare outcomes, clustered users, unequal variances or a different stopping rule need a calculation matching that design.
Allocate information as well as exposure#
| Candidate fraction | Approximate total users |
|---|---|
| 0.50 | 4780 |
| 0.20 | 7469 |
| 0.10 | 13278 |
The term is largest at one half. With the stated equal per-unit variability and cost, balanced allocation gives the most information per total user. A smaller candidate share can still be the correct risk decision; it just requires more total observations for the same planning target. These rounded totals do not select an automatic ramp or replace integer allocation and power verification.
Keep eligibility independent of the observed treatment effect#
Assign at a stable unit, such as user, when repeated requests from one user share outcomes. Analyse that unit or use a justified clustered method. Treating every correlated request as independent can make uncertainty artificially small.
If only some users can encounter the changed feature, predefine that eligibility. Selecting users afterward because the candidate made them engage conditions on a treatment consequence and can change the comparison. Keep assignment, actual exposure and outcome availability distinct so missing telemetry does not masquerade as product improvement.
Wait for the outcome that was defined#
Reaching a count is not enough when outcomes mature later. A user assigned just before analysis may not yet have had the full observation window. Compare completed windows or use a method designed for censored observations. Include relevant calendar variation and record the dates and versions represented.
Longer is not automatically better. A model, eligibility rule or surrounding product that changes midway creates a different intervention. Freeze the intended comparison where possible and record deviations rather than silently pooling incompatible periods.
Inspect safely without selecting a lucky stopping time#
Operational monitoring may stop harm at any time. That does not make an ordinary fixed-sample significance statement valid at an outcome-selected stopping time. Johari and coauthors discuss this distinction and methods designed for continuing inspection. Our source demonstrates the problem using a separate exact finite calculation, not their experimental data or method implementation.
Imagine independent fair binary outcomes under a null hypothesis. After outcomes with successes, a one-sided exact tail is
Compare a single look at 20 with looks at 4, 8, 12, 16 and 20. The program counts all equally likely paths by dynamic programming and records whether any look crosses its threshold.
| Decision rule under this fair null | Rejecting paths | Exact rejection probability |
|---|---|---|
| Only at 20, threshold 0.05 | 21700 | 0.0206947 |
| Any of five looks, each threshold 0.05 | 68504 | 0.0653305 |
| Any of five looks, each threshold 0.01 | 11102 | 0.0105877 |
The fixed test is conservative because counts are discrete. Repeated unadjusted inspection nevertheless exceeds 0.05. Giving each of five prespecified looks at most 0.01 bounds the probability of any false rejection by their sum, without assuming independent looks. Here the exact probability is lower still. This tiny illustration is not a universal recommendation to use this conservative correction; a sequential method should match the planned experiment and estimand.
Check whether the comparison exists in the logs#
A precise interval cannot repair incorrect assignment or selective observation. Before interpreting outcome differences, verify identity, counts, timestamps, deduplication and the relationship between assigned and analysed users. Separate a result about the logged population from a claim about everyone intended to receive the change.
Compare assignment counts with the planned ratio#
For an independently specified 50/50 assignment of 4800 users, observed counts 2900 and 1900 yield
The one-degree-of-freedom chi-square approximation gives a very small tail probability. Investigate before using the outcome result. Candidate users might disappear after a failure, a filter may be applied to only one arm, or the planned assignment might not be the one deployed. The count check detects a discrepancy; it does not identify which mechanism caused it. Fabijan and coauthors treat sample-ratio mismatch as a diagnostic signal rather than a diagnosis.
Exercise the system with identical variants#
An A/A test sends both labels to equivalent behaviour while exercising assignment and measurement. It can reveal asymmetric logging, unstable identifiers or an analysis pipeline that repeatedly discovers effects where none was introduced. One nonsignificant A/A result does not certify every future experiment, and occasional nominal false positives are compatible with a correctly calibrated test.
Separate temporary reactions from the target horizon#
A different preview layout may attract initial attention or inconvenience users accustomed to the earlier one. Define whether the decision concerns first use, sustained use or both. Report the time profile against a predeclared horizon; choosing the best-looking day after inspection gives another selected result. Continue observing a rollout when the decision depends on durable behaviour.
Account for shared resources and shared users#
A candidate can consume a shared queue and slow control users. Users can share generated artifacts across variants. Then one user’s outcome depends on other assignments, violating the simple isolated-user model. A change in randomization unit or an explicit interference design may be needed. Increasing the nominal sample count does not remove this structural problem.
Distinguish improvement from acceptable degradation#
In a new constructed result, each arm has 2400 independent users with a completed binary outcome. The baseline has 960 successes and the candidate 1048. The estimated difference is . The unpooled standard error is
A 95% normal interval is approximately . The pooled-null two-sided z-test gives . Under the stated fixed-sample assumptions, these support a positive difference; they do not prove guardrails passed, telemetry is complete or the effect will persist. The normal interval is an approximation with known coverage limits, not a posterior probability for this particular parameter interval.
For a separate cheaper candidate, keep 960 baseline successes but use 948 candidate successes. The difference is . A two-sided test gives , which is not evidence of equivalence. If the predeclared acceptable absolute loss is 0.02, require the one-sided 95% lower bound to exceed . Its approximate value is , so this constructed result does not establish non-inferiority. Lower cost alone does not change that statistical conclusion.
Attribute clicks within an interleaved slate#
Team-draft interleaving is a paired ranking comparison described by Radlinski, Kurup and Joachims. It combines results into one slate, skips already selected documents and records which ranker contributed each item. At tied contribution counts, randomized choice decides which ranker picks next; otherwise the smaller team picks. No code or illustrated ranking from their paper is reused here.
Our independently specified lists are A: quartz, cedar, reed, linen, plum and B: linen, quartz, spruce, reed, amber. With illustrative tie outcomes B then A, the four picks come from B, A, A, B, producing linen, quartz, cedar, spruce. A stipulated click on cedar is credited to A. The source replays this fixed illustrative sequence; it does not simulate user preferences or establish a ranking-quality effect.
Repeated comparisons require the designed randomization, treatment of ties and suitable user/query aggregation. A single credited click is not evidence of a general winner. Nor does this click-based comparison automatically measure long-term learning, revenue or the effect of replacing the whole page.
Adaptive allocation changes the inference problem#
A bandit updates exposure using observed rewards to balance learning with immediate reward. Thompson sampling, discussed by Russo and coauthors, selects actions through samples from an updated model of uncertainty. This can be appropriate when reward during the experiment is part of the objective.
Adaptive assignment also means later observations arrive under a policy influenced by earlier outcomes. A fixed-allocation analysis cannot simply ignore that history. Retain the policy version, assignment probabilities and reward definition; use an inference or evaluation method suited to that design. Delayed rewards, nonstationarity and rare harms can make fast adaptation misleading. We do not run a bandit or reuse the tutorial’s simulations in this fixture.
Keep the population visible after a win#
An independently specified mixture illustrates why aggregate improvement needs interpretation:
| Group | Baseline successes / users | Candidate successes / users |
|---|---|---|
| Easy | 16 / 20 | 60 / 80 |
| Hard | 24 / 80 | 5 / 20 |
The baseline succeeds for 40% overall and the candidate for 65%. Within each group, however, the candidate is five percentage points worse: 75% versus 80%, and 25% versus 30%. The candidate simply has more easy cases. Standardizing both to equal group weights gives a difference of instead of the naive .
This table is not presented as a valid randomized trial. It demonstrates why a changed rollout population or treatment-dependent analysis filter can reverse the aggregate impression. Use appropriate pre-treatment strata, investigate how the mixture changed and preserve the comparison population in the release record. After full exposure, keep the outcome and guardrails observable, because a completed experiment is evidence for its tested conditions, not a permanent guarantee.
What to retain#
Identify the exact release and unit of assignment. Give each exposure stage a question and an abort path. Plan effect, sample size, duration and stopping together. Check assignment and telemetry before interpreting outcomes. Failure to reject a difference is not proof of non-inferiority. Preserve the population and adaptive policy that produced the evidence.
Reproduce the example#
The original standard-library program calculates the stated planning totals, intervals, exact stopping-path counts, sample-ratio statistic, illustrative ranking trace and mixture reversal. Saved outputs include inputs and assumptions. No service is contacted and no real experiment is created.
Next#
Monitoring and drift follows the accepted release over time, separating changed inputs from delayed evidence about quality.
References#
- Alec Warner and Štěpán Davidovič. Canarying Releases, Google SRE Workbook, 2018: partial exposure and evaluation. No chapter example, code or diagram reused.
- NIST/SEMATECH. Comparing two proportions; NIST Dataplot, difference-of-proportions intervals, read 13 November 2026: large-sample tests, normal intervals and coverage limits. Inputs and computations here are original.
- Aleksander Fabijan and coauthors. Diagnosing Sample Ratio Mismatch, KDD 2019: primary abstract’s diagnostic framing; no taxonomy examples or data reused.
- Ramesh Johari, Pete Koomen, Leonid Pekelis and David Walsh. Peeking at A/B Tests, KDD 2017; author’s abstract: continuing inspection needs suitable inference. The finite fair-outcome calculation is independently authored.
- Filip Radlinski, Madhu Kurup and Thorsten Joachims. How Does Clickthrough Data Reflect Retrieval Quality?, CIKM 2008, section 5.2: team-draft mechanism. No paper prose, diagram, ranking example, code or result reproduced.
- Daniel Russo, Benjamin Van Roy, Abbas Kazerouni, Ian Osband and Zheng Wen. A Tutorial on Thompson Sampling, 2020 revision: adaptive exploration and reward. No example, model or simulation copied.