Step 5 of 6

Deployment & MLOps

The nine-stage deployment pipeline, the seven things that can change an AI system's output, serving stacks, and inference patterns.

13 min read

Shipping traditional software means shipping code. Shipping AI means shipping code and models, prompts, retrieval indexes, embeddings, configuration, and data - any of which can change your system's output without a single line of code changing. MLOps is the discipline of shipping all of it safely, reproducibly, and reversibly.

The AI deployment pipeline#

  1. 01BuildCode, prompts, pipelines
  2. 02TestUnit + integration
  3. 03EvaluateQuality on eval sets
  4. 04PackageContainer + artifacts
  5. 05RegisterVersioned in a registry
  6. 06StageShadow / canary
  7. 07DeployGradual rollout
  8. 08MonitorQuality, drift, cost
  9. 09ImproveFailures → new data & tests

↺ Improve feeds back into Build

Nine stages. The two that separate AI from ordinary CI/CD are Evaluate and Monitor - quality is statistical, and it drifts.

Build. Code, prompt templates, and data pipelines live in version control. Prompts are code - review them like code.

Test. Ordinary unit and integration tests for everything deterministic: parsing, tool functions, retrieval filters, API contracts.

Evaluate. Run the candidate against a fixed evaluation set and compare to the current production version. Gate the release on it: "faithfulness must not drop more than 1 point; p95 latency must stay under 3 s."

Package. Build an immutable container with pinned dependencies. Reference model weights and indexes by version or hash, never "latest."

Register. Record the exact combination - code commit, model version, prompt version, index version, config - in a model registry (MLflow and similar tools do this) so you know precisely what's running.

Stage. Validate with real traffic safely: shadow mode (run the new version on live requests without showing users the output) or a canary (send it a small percentage of traffic).

Deploy. Roll out gradually, watching metrics at each step, with automated rollback on regression.

Monitor. Track quality signals (feedback, eval scores on sampled traffic), data and prediction drift, latency, errors, and cost.

Improve. Turn production failures into new evaluation cases and training data, then go round again.

Seven things that can change your output#

1

Code

Application logic, parsing, orchestration.

2

Model

A new model version - including silent updates behind a provider alias.

3

Prompt

Instructions, examples, output format.

4

Retrieval source

Documents added, removed, or edited in the knowledge base.

5

Embeddings

A new embedding model makes old and new vectors incompatible - re-index everything.

6

Configuration

Temperature, top-k, chunk size, thresholds, feature flags.

7

Training data

For fine-tuned or custom models, any change to the dataset.

Serving stacks#

StackWhat it isReach for it when
Managed APIsModel providers' hosted endpointsFastest path; no infrastructure
vLLM / SGLangHigh-throughput LLM inference serversSelf-hosting open LLMs on GPUs
NVIDIA TritonMulti-framework inference server with dynamic batchingMixed model types (vision, tabular, LLM) on NVIDIA hardware
KServeKubernetes-native model serving with autoscalingYou already run on Kubernetes
TorchServeServing for PyTorch modelsCustom PyTorch models (note: in limited maintenance - check status before adopting)
Serverless GPU platformsPay-per-second GPU containersSpiky traffic, small teams

Inference patterns#

Batch

throughput

Score large datasets on a schedule - nightly churn predictions, bulk document classification. Cheapest per item; results aren't immediate.

Online (real-time)

latency

Request-response behind an API - chat, search, recommendations. Optimize p95 latency and availability.

Streaming

continuous

Process events as they arrive from a queue or stream - fraud detection, live moderation. Also: token streaming to users in chat UIs.

Edge

on-device

Run small models on phones, browsers, or devices - for privacy, offline use, and zero network latency. Constrained by memory and power.

Release strategies#

StrategyHowWhy
ShadowNew version runs on real traffic; outputs logged, not shownCompare quality with zero user risk
CanarySmall % of traffic → new version, then ramp upCatch regressions early, limit blast radius
A/B testSplit traffic, compare outcome metricsProve a change improves what users care about
Blue/greenTwo full environments; switch traffic at onceInstant rollback
Feature flagsToggle prompts/models per user or segmentDecouple deploy from release
Model registry
A versioned catalog (e.g., MLflow) that records the exact combination of code, model, prompt, and config for each release - the basis of reproducible rollback.
Shadow mode
Running a new version on live requests without showing users its output - a zero-risk way to compare quality before switching.
Canary release
Sending a small percentage of traffic to the new version while watching metrics - catches regressions with a limited blast radius.
Drift
When the data a model sees in production gradually diverges from its training data, degrading predictions over time.

Further reading

Search Data Science After Dark

Search across prompts, models, papers, guides, and library topics.