Pidoku

Model Rollouts

Module 23 Lesson 23.g 1h Difficulty 3/5

Prerequisites 20.j, 11.k


Before you start: words you need#

WordPlain meaning
RolloutMoving production traffic from one version of the serving stack to the next.
CanaryA small share of traffic sent to the new version first, to find problems before everyone sees them (20.j).
Shadow trafficCopies of real requests sent to the new version, with its answers thrown away.
GuardA rule on a metric (“p95 TTFT more than 1.3× baseline for 10 minutes”) that stops or reverses a rollout.
SoakRunning the new version at 100% for days while the old one can still be brought back.
Evaluation suiteA fixed set of prompts and checks run against a model to score its quality.
Chat templateThe text format that turns a list of messages into the model’s prompt (16.e). One wrong character changes behaviour.

1. What is it?#

20.j covers the mechanics: what a version must record, rolling vs blue/green vs canary vs shadow, weighted traffic splitting, stickiness, and A/B tests. This lesson is the operating process: what a safe release of a model, quantization, engine or template change looks like from build to clean-up, which signals gate each step, and what to do when a regression gets through.

A “model rollout” here means any change that can alter outputs: new weights, a new quantization, a new engine version, new kernels, a new chat template, new sampling defaults.


2. Why does it matter?#

CODE ROLLOUT                        MODEL ROLLOUT
failures are errors (5xx)           failures are "worse answers"
seen in minutes                     seen in hours to days
rollback is instant                 rollback needs the old weights loaded and warm
artifact is megabytes               artifact is 10–800 GB
same input → same output            outputs vary by design (sampling, batching, 11.k)
tests are pass/fail                 evaluation is statistical

The normal deployment safety machinery cannot see the failure that matters. Every dashboard can be green while answers get worse.

flowchart LR
  B["Build<br/><small>pinned weights, engine, config</small>"] --> EV["Offline evaluation<br/><small>quality and performance gates</small>"]
  EV --> SH["Shadow"]
  SH --> C1["Canary 1–5%"]
  C1 --> G{"Guards hold?"}
  G -->|"yes"| C2["25% → 50% → 100%"]
  G -->|"tier 1 breached"| RB["Automatic rollback"]
  G -->|"tier 2 breached"| H["Halt, human decides"]
  C2 --> SO["Soak 48–72 h<br/><small>old version still warm</small>"]
  class B,EV neutral
  class SH,C1 io
  class G queue
  class C2,SO compute
  class RB,H warn

3. Simple analogy#

A restaurant changing its recipe. It does not change the menu for every customer on Monday. The chef cooks it for the staff first (offline evaluation), then serves it to a few tables without telling them (canary), watching what comes back half-eaten (output signals). Only after a week of no complaints (soak) does the old recipe card leave the kitchen.


4. Tiny example#

Three canaries against the same baseline, judged by the guards of section 5 (the program is in section 6):

v15 (same weights, new engine)      → continue
v16 (FP8 → INT4 weights)            → HALT: answers 29% longer, 77% more cut off at max_tokens,
                                      structured output valid 96% instead of 99.5%
v17 (new chat template)             → ROLL BACK: 5xx errors doubled

v16 has better latency than the baseline. Every tier-1 dashboard is green. Only the cheap output signals show that the model has started rambling.


5. Technical explanation#

The release process#

STAGE 0 — PREPARE
  □ artifact built and checksummed; full version record in the registry (20.j, 21.b)
  □ quantization done offline, with its config and calibration set recorded
  □ engine artifacts (compile caches, TensorRT-LLM engines) built for each GPU type
  □ copied to every region's storage, node caches pre-loaded (23.f)

STAGE 1 — OFFLINE EVALUATION
  □ numerical: logit difference, KL divergence, top-1 agreement against the reference
  □ task: your evaluation suite, on YOUR domain, not just public benchmarks
  □ behavioural: long generations, instruction following, structured output validity,
    tool calls, refusals, reasoning-length distribution for reasoning models
  □ regression set: tricky prompts from past incidents
  □ performance: capacity at the SLO (23.b), memory headroom
  → GATE: all within tolerance, or a written waiver

STAGE 2 — SHADOW (recommended for engine and kernel changes)
  □ mirror 1–5% of traffic for 2–24 hours; discard the answers
  □ compare latency, memory, crash rate, OOMs
  → GATE: no crashes, latency within 10%, no OOM

STAGE 3 — CANARY
  □ 1% of traffic, one region, non-premium tiers, split by conversation (20.j)
  □ automatic guards on (below)
  □ at least 2–4 hours, or until the sample is large enough (20.j shows how to size it)
  → GATE: tier 1 and tier 2 guards hold

STAGE 4 — PROGRESSIVE ROLLOUT
  □ 1% → 5% → 25% → 50% → 100%, at least an hour per step, longer early
  □ guards stay on; a human checks at 25% and 50%

STAGE 5 — SOAK
  □ 100% for 48–72 hours, old version still deployable in seconds
  □ watch the slow signals: regeneration rate, conversation length, task completion,
    support tickets, LLM-as-judge on sampled pairs
  → GATE: no degradation → retire the old version

STAGE 6 — CLEAN UP
  □ remove the old replicas; keep the old artifact for at least 30 days
  □ update the registry; write down what changed and what was learned

Stage 5 is the one cut under schedule pressure, and it is where the real quality signals appear. Defend it.

Signals by how fast they move#

MINUTES (automatic rollback)
  5xx and timeout rate, p95 TTFT, p95 ITL, OOMs and crashes, throughput per GPU

MINUTES TO HOURS (halt and alert)
  output length distribution          ← the most sensitive cheap signal
  finish-reason mix (stop vs length vs stop-string)
  structured output validity, tool-call success
  refusal rate
  reasoning-token length (reasoning models)
  prefix-cache hit rate               ← a template change moves it

HOURS TO DAYS (human review)
  regeneration rate, conversation length, task completion,
  explicit feedback, support tickets, LLM-as-judge on paired samples

The middle tier is what most teams lack, and it is where regressions show first.

Guards#

YAML
guards:
  # Tier 1 — automatic rollback
  - {metric: error_rate_5xx,        condition: "> 1.5 × baseline for 5m",   action: rollback}
  - {metric: p95_ttft_ms,           condition: "> 1.3 × baseline for 10m",  action: rollback}
  - {metric: p95_itl_ms,            condition: "> 1.25 × baseline for 10m", action: rollback}
  - {metric: oom_count,             condition: "> 0 in 15m",                action: rollback}
  # Tier 2 — halt the rollout and page a human
  - {metric: mean_output_tokens,          condition: "outside [0.80, 1.25] × baseline for 30m", action: halt}
  - {metric: finish_reason_length_share,  condition: "> 1.4 × baseline for 30m",                action: halt}
  - {metric: structured_output_valid,     condition: "< 0.98 × baseline for 30m",               action: halt}
  - {metric: refusal_rate,                condition: "outside [0.7, 1.5] × baseline for 60m",   action: halt}

Tier 2 halts rather than rolls back because those signals are noisier: a product change can move output length too. A human should look before reverting. Argo Rollouts, Flagger and KServe express these as analysis steps against Prometheus (tools in 20.j).

Compare the canary with the baseline at the same time, not with last week: traffic mix changes by hour, and a canary started at 09:00 compared with a baseline from 03:00 will always look different.

Rollback readiness#

SECONDS     the old version still RUNNING; rollback is a traffic shift
MINUTES     old weights in node caches, engine artifacts built; redeploy and warm up
AN HOUR+    old artifact only in object storage; download, load, warm up, in every region

Keeping the old version warm costs its replicas for the rollout and soak window: for a 10-node deployment and a 72-hour soak, that is 720 extra node-hours, roughly $14,000 at $20 per node-hour. Expensive, but a rollback in seconds instead of an hour of degraded answers for every user is usually worth it for risky changes. For low-risk ones, scale the old pool down to a small warm floor after the canary passes.

Decide in writing whether you are paying for fast rollback, and for how long. “We’ll roll back if needed” is not a plan unless the old version can return within the time your SLO allows.

When a regression gets through#

1. ROLL BACK FIRST, investigate second. Do not debug in production while users suffer.
2. KEEP EVIDENCE: sampled requests and responses from the bad version (within your
   privacy policy, 23.i) so you can reproduce.
3. REPRODUCE OFFLINE with the exact serving configuration, not a reference script.
4. FIND THE CAUSE. The usual ones, roughly in order:
     - quantization damaged a capability the evaluation suite did not test
     - the chat template changed subtly
     - sampling defaults changed (generation_config.json, 16.b)
     - a kernel or backend change moved numerics beyond tolerance
     - the checkpoint is not the one that was evaluated
5. ADD THE TEST to the evaluation suite, permanently.
6. WRITE THE POSTMORTEM, including why the existing gates missed it.

Step 5 compounds: an evaluation suite that grows with every incident becomes genuinely protective within a year.

Special cases#

ENGINE UPGRADE (same weights)   shadow first (crashes, memory, speed); still check numerics:
                                kernels change outputs. Read the release notes for changed
                                defaults (KV cache dtype, scheduler, removed features).
QUANTIZATION CHANGE             the highest-risk change type: full stages 1–5, 72 h soak.
CHAT TEMPLATE CHANGE            render a corpus of conversations before and after and diff
                                the prompts byte for byte; expect the prefix cache to reset.
SAMPLING DEFAULT CHANGE         affects every caller who does not set parameters: canary it.
SPECULATIVE DECODING ON/OFF     output distribution should not change (12.n), but bugs can;
                                treat as an engine change.
EMERGENCY SECURITY PATCH        shadow or 5% canary for 15 minutes, then full; record the
                                accepted risk; soak afterwards.

6. Under the hood#

The guards as code: each canary metric divided by the baseline, checked against its allowed range.

Go
// guards.go — compare a canary with the baseline and decide: continue, halt, or roll back.
package main

import "fmt"

type guard struct {
	metric   string
	lo, hi   float64 // allowed range for canary ÷ baseline
	rollback bool    // true: roll back automatically; false: halt and page a human
}

var guards = []guard{
	// Tier 1: clear, fast signals → automatic rollback
	{"error_rate_5xx", 0, 1.5, true},
	{"p95_ttft_ms", 0, 1.3, true},
	{"p95_itl_ms", 0, 1.25, true},
	// Tier 2: noisier quality signals → stop the rollout, a human decides
	{"mean_output_tokens", 0.80, 1.25, false},
	{"finish_reason_length_share", 0, 1.4, false},
	{"structured_output_valid", 0.98, 1.01, false},
	{"refusal_rate", 0.7, 1.5, false},
}

func decide(baseline, canary map[string]float64) string {
	verdict := "continue"
	for _, g := range guards {
		r := canary[g.metric] / baseline[g.metric]
		if r >= g.lo && r <= g.hi {
			continue
		}
		fmt.Printf("    %-27s canary/baseline = %.2f (allowed %.2f–%.2f)\n", g.metric, r, g.lo, g.hi)
		if g.rollback {
			return "ROLL BACK"
		}
		verdict = "HALT, page a human"
	}
	return verdict
}

func main() {
	baseline := map[string]float64{"error_rate_5xx": 0.002, "p95_ttft_ms": 620, "p95_itl_ms": 34,
		"mean_output_tokens": 310, "finish_reason_length_share": 0.04,
		"structured_output_valid": 0.995, "refusal_rate": 0.012}

	canaries := []struct {
		name string
		m    map[string]float64
	}{
		{"v15 (same weights, new engine)", map[string]float64{"error_rate_5xx": 0.0022, "p95_ttft_ms": 640,
			"p95_itl_ms": 35, "mean_output_tokens": 318, "finish_reason_length_share": 0.042,
			"structured_output_valid": 0.994, "refusal_rate": 0.013}},
		{"v16 (FP8 → INT4 weights)", map[string]float64{"error_rate_5xx": 0.002, "p95_ttft_ms": 600,
			"p95_itl_ms": 29, "mean_output_tokens": 401, "finish_reason_length_share": 0.071,
			"structured_output_valid": 0.962, "refusal_rate": 0.011}},
		{"v17 (new chat template)", map[string]float64{"error_rate_5xx": 0.004, "p95_ttft_ms": 910,
			"p95_itl_ms": 36, "mean_output_tokens": 300, "finish_reason_length_share": 0.04,
			"structured_output_valid": 0.993, "refusal_rate": 0.012}},
	}
	for _, c := range canaries {
		fmt.Printf("%s\n", c.name)
		fmt.Printf("  → %s\n\n", decide(baseline, c.m))
	}
}

Output:

v15 (same weights, new engine)
  → continue

v16 (FP8 → INT4 weights)
    mean_output_tokens          canary/baseline = 1.29 (allowed 0.80–1.25)
    finish_reason_length_share  canary/baseline = 1.77 (allowed 0.00–1.40)
    structured_output_valid     canary/baseline = 0.97 (allowed 0.98–1.01)
  → HALT, page a human

v17 (new chat template)
    error_rate_5xx              canary/baseline = 2.00 (allowed 0.00–1.50)
  → ROLL BACK

A real guard also needs a minimum sample (a 1% canary may see too few requests in 5 minutes to judge an error rate) and a duration (“for 10 minutes”), so one noisy window does not trigger a rollback.


7. Performance implications#

  • Rollouts cost capacity. Canary, shadow and a warm old version all need GPUs beyond the steady fleet. Plan them into the capacity plan (23.b) as a standing reserve.
  • New replicas start cold. Their prefix caches are empty, so TTFT is worse for the first minutes; guards on TTFT need a warm-up allowance, or they fire on every step.
  • Shadow traffic doubles inference for the mirrored share. Keep it small and short.

8. Production implications#

  • The version record covers the whole serving stack, not just the checkpoint (20.j).
  • Put model_version on every metric, log line and response header. Without it, nothing can be correlated with a deployment.
  • Build the middle-tier signals: output length, finish reasons, structured validity. They are cheap and they catch quality regressions first.
  • Keep the old version warm during risky rollouts, and decide for how long.
  • Soak for 48–72 hours.
  • Grow the evaluation suite from incidents.
  • Do not roll out model changes into a low-staffing window (Friday evening, holidays).

9. Common mistakes#

  1. Treating a model rollout like a code rollout. Different failure, different timescale.
  2. Evaluating only on public benchmarks. They miss what your users notice.
  3. No middle-tier signals. Regressions are found through support tickets.
  4. Cutting the soak.
  5. Rolling back slowly because the old version was not kept deployable.
  6. An incomplete version record. Nothing can be reproduced or correlated.
  7. Debugging in production instead of rolling back first.
  8. Comparing the canary with a baseline from a different time of day.
  9. Not adding a test after an incident.

10. Hands-on exercise#

  1. Run guards.go. Add a reasoning-model guard on mean reasoning tokens, and a canary whose reasoning length doubled while its answers stayed the same. Which tier should that guard be in?
  2. Implement the middle-tier signals (output length histogram, finish-reason mix, structured validity) for a service and record a week of baselines.
  3. Deploy a deliberately degraded version (INT4 where you normally run FP8) at 5%. Which signal moves first, and after how long?
  4. Time a full rollback from 100% with the old version cold, then with it warm. Put a dollar figure on the difference.
  5. Take a past quality incident (yours or a published one) and write the evaluation test that would have caught it.

11. Interview questions#

  1. Why can standard deployment safety not catch LLM quality regressions?
  2. Walk me through a safe model rollout, stage by stage.
  3. Which signals belong in automatic rollback, and which in halt-and-alert? Why?
  4. What does keeping the old version warm cost, and when is it worth it?
  5. Why is a chat template change dangerous, and how do you validate it?
  6. You find a quality regression after a full rollout. What do you do, in order?
  7. Why must a canary be compared with a baseline at the same time of day?

12. Further reading#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in