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#
- 01BuildCode, prompts, pipelines
- 02TestUnit + integration
- 03EvaluateQuality on eval sets
- 04PackageContainer + artifacts
- 05RegisterVersioned in a registry
- 06StageShadow / canary
- 07DeployGradual rollout
- 08MonitorQuality, drift, cost
- 09ImproveFailures → new data & tests
↺ Improve feeds back into Build
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#
Code
Application logic, parsing, orchestration.
Model
A new model version - including silent updates behind a provider alias.
Prompt
Instructions, examples, output format.
Retrieval source
Documents added, removed, or edited in the knowledge base.
Embeddings
A new embedding model makes old and new vectors incompatible - re-index everything.
Configuration
Temperature, top-k, chunk size, thresholds, feature flags.
Training data
For fine-tuned or custom models, any change to the dataset.
Serving stacks#
| Stack | What it is | Reach for it when |
|---|---|---|
| Managed APIs | Model providers' hosted endpoints | Fastest path; no infrastructure |
| vLLM / SGLang | High-throughput LLM inference servers | Self-hosting open LLMs on GPUs |
| NVIDIA Triton | Multi-framework inference server with dynamic batching | Mixed model types (vision, tabular, LLM) on NVIDIA hardware |
| KServe | Kubernetes-native model serving with autoscaling | You already run on Kubernetes |
| TorchServe | Serving for PyTorch models | Custom PyTorch models (note: in limited maintenance - check status before adopting) |
| Serverless GPU platforms | Pay-per-second GPU containers | Spiky traffic, small teams |
Inference patterns#
Batch
throughputScore large datasets on a schedule - nightly churn predictions, bulk document classification. Cheapest per item; results aren't immediate.
Online (real-time)
latencyRequest-response behind an API - chat, search, recommendations. Optimize p95 latency and availability.
Streaming
continuousProcess events as they arrive from a queue or stream - fraud detection, live moderation. Also: token streaming to users in chat UIs.
Edge
on-deviceRun small models on phones, browsers, or devices - for privacy, offline use, and zero network latency. Constrained by memory and power.
Release strategies#
| Strategy | How | Why |
|---|---|---|
| Shadow | New version runs on real traffic; outputs logged, not shown | Compare quality with zero user risk |
| Canary | Small % of traffic → new version, then ramp up | Catch regressions early, limit blast radius |
| A/B test | Split traffic, compare outcome metrics | Prove a change improves what users care about |
| Blue/green | Two full environments; switch traffic at once | Instant rollback |
| Feature flags | Toggle prompts/models per user or segment | Decouple 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.