Pidoku

Versioning, Canary Deployments, and A/B Testing

Module 20 Lesson 20.j 1h Difficulty 3/5

Prerequisites 20.f, 20.g, 11.k


Before you start: words you need#

WordPlain meaning
VersionAn exact description of what is serving: weights, quantization, engine, settings, template.
CanarySending a small share of traffic to a new version first, and widening only if it behaves.
Blue/greenRunning the old (“blue”) and new (“green”) fleets side by side and switching traffic between them at once.
Shadow (mirror) trafficSending a copy of real requests to the new version and throwing its answers away.
A/B testA controlled experiment: users are split at random between two versions, and a metric is compared.
StickinessKeeping one user or conversation on the same version for the whole test.
Statistical powerThe chance an experiment detects a real difference of a given size. 80% is the usual target.

1. What is it?#

How you change what is serving without breaking anything, and how you find out whether the change was good:

VERSIONING   knowing exactly what is deployed
ROLLOUT      exposing a change gradually (canary, blue/green, rolling, shadow)
A/B TESTING  measuring whether the change is better
ROLLBACK     undoing it quickly when it is not

The LLM-specific difficulty: the usual failure is “slightly worse answers”, which no error rate or latency graph shows.

This lesson covers the mechanisms: what a version is, how traffic is split and kept sticky, and how big an experiment must be. Lesson 23.g is the production release process built on them: the stages, the rollback guards and the rollback plan.

Facts checked on 12 November 2026.


2. Why is it different for LLMs?#

ORDINARY SERVICE                     LLM SERVICE
errors are 4xx/5xx                   errors include "the answer got worse"
a canary shows errors in minutes     a quality regression takes hours to days to see
rollback is instant                  rollback may need weights reloaded (minutes)
"the version" is the code            version = weights + quantization + engine + kernels
                                       + parallelism + sampling defaults + template
the same input gives the same output output varies run to run (11.k)

The fourth row is the one teams get wrong. “We deployed Qwen3-32B” is not a version. Changing the engine release, the attention backend or the KV cache dtype can change outputs as much as changing the weights.


3. Simple analogy#

A restaurant changing its recipe.

The version is the full recipe card, including the oven and the brand of flour, not just the dish’s name. A canary is serving the new recipe to one table in twenty. An A/B test is giving half the regulars the new recipe for a month and counting who comes back. Rolling back is easy only if you kept the old ingredients in the kitchen.


4. Tiny example: how big must an A/B test be?#

Suppose 8% of conversations today contain a regenerated answer (the user asked again), and you want to know whether a new quantized version changes that.

Go
// power.go — how many conversations does an A/B test need to see a change in a rate?
package main

import (
	"fmt"
	"math"
)

// perArm is the sample size per variant to detect p1 → p2 with a two-sided test at 5%
// significance and 80% power (the normal approximation for two proportions).
func perArm(p1, p2 float64) float64 {
	const zAlpha, zBeta = 1.96, 0.84
	v := p1*(1-p1) + p2*(1-p2)
	return math.Ceil((zAlpha + zBeta) * (zAlpha + zBeta) * v / ((p1 - p2) * (p1 - p2)))
}

func main() {
	const (
		base    = 0.08    // 8% of conversations have a regenerated answer today
		perDay  = 50000.0 // conversations per day
		canary  = 0.05    // share of traffic on the new version during a canary
		abSplit = 0.5     // share on the new version during a 50/50 A/B test
	)
	fmt.Printf("baseline regeneration rate %.0f%%, %.0f conversations/day\n", base*100, perDay)
	fmt.Printf("%-16s %12s %18s %14s\n", "relative change", "per variant", "days at 5% canary", "days at 50/50")
	for _, rel := range []float64{0.20, 0.10, 0.05, 0.03} {
		n := perArm(base, base*(1+rel))
		fmt.Printf("%+15.0f%% %12.0f %18.1f %14.1f\n", rel*100, n, n/(perDay*canary), n/(perDay*abSplit))
	}
}

Output:

baseline regeneration rate 8%, 50000 conversations/day
relative change   per variant  days at 5% canary  days at 50/50
            +20%         4912                2.0            0.2
            +10%        18848                7.5            0.8
             +5%        73767               29.5            3.0
             +3%       203092               81.2            8.1

How to read it:

  • A 5% canary cannot measure quality. Even a large (20%) change takes two days to see; a 3% change, typical of a quantization step, takes months.
  • A 50/50 test can, in days, but exposes half your users to the change.
  • So a canary answers “is it broken?” (errors, latency, crashes, obvious behaviour shifts), and an A/B test or an offline evaluation answers “is it better or worse?”. Plan for both.

5. Technical explanation#

What a version must capture#

model_version = {
  weights:        checkpoint URI and revision (commit hash)
  quantization:   method, bits, group size, skipped layers, calibration set hash
  engine:         vLLM 0.32.0, or a TensorRT-LLM engine hash
  kernels:        attention backend, GEMM backend
  parallelism:    tensor and pipeline parallel sizes
  precision:      dtype, KV cache dtype
  chat_template:  hash
  tokenizer:      revision or hash
  sampling:       server-side defaults (vLLM reads generation_config.json, 16.b)
  speculative:    draft model or method, if any
  runtime:        CUDA and driver versions
}

Two deployments differing in any of these can produce different outputs. Record all of it in the registry (21.b), attach a short version id as a label on every metric, and return it in a response header (for example X-Model-Version) so user reports can be matched to a deployment.

Deployment strategies#

ROLLING
  Replace replicas one at a time.
  ✓ no extra GPUs
  ✗ slow: each replica takes minutes to drain and start
  ✗ both versions serve side by side for the whole window
  → the default for low-risk changes; set maxUnavailable: 0 and a long grace period (20.g)

BLUE/GREEN
  Bring up the whole new fleet, switch traffic, keep the old one running.
  ✓ rollback in seconds (switch back)
  ✗ 2× GPUs during the switch: expensive for LLMs
  → high-risk changes, if you can afford it

CANARY
  Send a small share to the new version and widen in steps.
  ✓ limits the blast radius
  ✓ real traffic before full exposure
  ✗ needs weighted traffic splitting, and enough traffic to see anything
  → the right default for model changes

SHADOW
  Copy a share of real requests to the new version; discard its answers.
  ✓ no user risk, real request mix
  ✗ costs inference for every mirrored request
  ✗ no user reaction to measure
  → engine upgrades and performance checks: catches crashes, OOMs, latency regressions

For a model or quantization change, canary with quality checks. For an engine upgrade, shadow first, then canary.

Splitting traffic#

The split happens at the gateway or router, by weight:

YAML
# Gateway API HTTPRoute: 95% to the current pool, 5% to the canary pool
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: chat
spec:
  parentRefs: [{name: inference-gateway}]
  rules:
    - backendRefs:
        - {group: inference.networking.k8s.io, kind: InferencePool, name: chat-v14, weight: 95}
        - {group: inference.networking.k8s.io, kind: InferencePool, name: chat-v15, weight: 5}

Each InferencePool (20.f) is one version’s replicas with its own endpoint picker. Tools that move the weights for you, in steps, and roll back on a metric:

ToolNotes
Argo Rollouts (v1.10)Canary and blue/green steps with analysis queries; Gateway API through a plugin
Flagger (v1.45)Progressive delivery driven by Prometheus checks; supports Gateway API
KServe LLMInferenceServiceCanary rollout of LLM deployments; end-to-end tests added in v0.21 (September 2026)
llm-d DisaggregatedSet (v1.0)Rolls prefill and decode replicas of one version together, with revision routing

For LoRA adapters, a version change is cheaper: load support-v4 beside support-v3 on the same replicas and split by the model name at the router. No new GPUs.

Stickiness#

Split by CONVERSATION (or user), never by request.

  hash(conversation_id) mod 100 < canary_percent  →  new version

If turn 1 is served by v14 and turn 2 by v15, the user sees an inconsistent voice, the prefix cache misses (each version has its own replicas), and your A/B statistics mix the two. A hash of the conversation id gives stickiness with no state; raising the percentage only moves conversations from old to new, never back.

What a canary watches#

In brief (23.g has the full set and the rollback guards):

MINUTES        errors, timeouts, p95 time to first token and inter-token latency,
               OOMs and crashes                                   → automatic rollback
MINUTES–HOURS  output length, finish-reason mix (stop vs length), refusal rate,
               structured-output validity, tool-call success      → halt and look
HOURS–DAYS     regeneration rate, thumbs, conversation length, task completion,
               LLM-as-judge on sampled pairs                     → the real decision

Output length is the cheapest early signal. A model that starts rambling or cutting off shows up in the length histogram within minutes, long before any evaluation finishes.

A/B tests for quality#

DESIGN
  - randomize by user or conversation, not by request
  - fix the metric and the sample size BEFORE starting (section 4)
  - run whole weeks if behaviour varies by weekday

METRICS THAT WORK
  - regeneration rate (the user asked again): a strong negative signal
  - turns to resolution, task completion (if your product can measure it)
  - explicit feedback: sparse and biased, but direct
  - LLM-as-judge on paired outputs: cheap, roughly agrees with people,
    but has position and length biases; randomize order

METRICS THAT MISLEAD
  - perplexity: not what users experience
  - public benchmarks: not your traffic
  - average answer length alone: longer is not better

Rollback#

Rollback in seconds needs the old version still running: a traffic shift, not a redeploy. Redeploying means a full cold start (20.g). Keep the old pool warm for the first hours of a rollout, and keep its weights in node caches and its compile caches on disk for longer. 23.g works through the cost.


6. Under the hood: why “the same model” gives different answers#

Even with identical weights, outputs move when:

  • The engine version changes a kernel, fusion or default (for example a new attention backend or a different default KV cache dtype).
  • Batch composition changes. Floating-point sums in different orders give slightly different results, so the same prompt can produce different tokens at batch 8 and batch 64 (11.k).
  • Parallelism changes. A different tensor-parallel size splits and sums matrices differently.
  • The chat template changes by one whitespace character.

That is why the version record includes the whole serving stack, and why a canary compares distributions (length, finish reasons, refusals) rather than exact strings.


7. Performance implications#

  • Canaries need capacity. A 5% canary still needs whole replicas; on a small fleet it may be one replica at very low utilization, so its latency looks better than production’s. Compare at similar load, or shadow at full rate.
  • Shadow traffic costs real GPU time. Mirroring 10% of traffic is 10% more inference.
  • Split versions split caches. Each version has its own prefix cache, so both run colder during a rollout. Expect slightly worse time to first token on both sides.
  • Blue/green doubles GPUs for its duration; rolling updates cost almost nothing extra but stretch the mixed-version window.

8. Production implications#

  • Record the full version and emit it as a label and a response header.
  • Canary every model change, with automatic rollback on the fast signals (23.g).
  • Shadow every engine upgrade before it sees users.
  • Make splits sticky by conversation or user.
  • Size A/B tests before running them, and accept that a canary only finds breakage.
  • Keep the old version warm during the first hours.
  • Version adapters like models, and roll them out by name at the router.

9. Common mistakes#

  1. Treating the checkpoint as the version. The serving stack is part of it.
  2. No quality signal in the rollout. Every conventional check passes while answers degrade.
  3. Per-request randomization. Users see both versions mid-conversation.
  4. Reading a small canary as a quality result. 5% for an afternoon tells you nothing about a 3% quality change.
  5. No automatic rollback on the fast signals.
  6. Rolling update with a short grace period. Truncated answers in every deploy.
  7. Old version not kept warm. Rollback takes as long as a deployment.

10. Hands-on exercise#

A. Size your test. Run power.go with your own baseline rate and daily traffic. What is the smallest change you can detect in one week at 5%, and at 50/50?

B. Write your version record. Fill in every field in section 5 for a model you serve. Which fields were you not recording?

C. Sticky split. Write a router that sends hash(conversation_id) mod 100 < p to the canary. Check that raising p from 5 to 25 never moves a conversation back to the old version.

D. Length as a signal. Serve a model at BF16 and at a 4-bit quantization. Send the same 2,000 prompts to both and compare output length distributions and finish reasons. How many samples do you need to see the difference?

E. Break it on purpose. Deploy a canary with a wrong chat template. Which signal fires first?


11. Interview questions#

  1. What makes up a “model version” for an LLM service?
  2. Why does conventional canary monitoring miss LLM quality regressions?
  3. Which early signals show a quality problem within minutes?
  4. Why randomize by user or conversation rather than by request?
  5. Compare rolling, blue/green, canary and shadow for a model change and for an engine upgrade.
  6. How many conversations do you need to detect a 5% change in a rate of 8%? What does that mean for a 5% canary?
  7. Why can identical weights give different outputs after an engine upgrade?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

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