AI Advanced · MLOps & AI Infrastructure

MLOps & AI Infrastructure

Training a model is a project; keeping it working is a job. MLOps is the discipline of shipping machine-learning models to production and keeping them reliable there — the data pipelines, serving stack, monitoring, versioning, and retraining loops that turn “it works in my notebook” into “it works for a million users at 3 a.m.” If you’ve built an agent or a RAG system, you’ve already met the surface; this page is the plumbing underneath.

☺ Explain it like I’m 10

Imagine you baked one amazing cake at home. That’s cool — but now you have to run a bakery: order flour every day, bake thousands of cakes, deliver them still warm, taste-test to make sure they haven’t gone stale, and re-bake the recipe when customers’ tastes change. MLOps is everything that turns one great cake into a bakery that never lets people down.

🐢Your host for this topic: Timmy the Turtle — Timmy keeps things reliable in the real world — and MLOps is how models stay reliable in production.

MLOps = DevOps for machine learning

☺ Like you’re 10: Regular software is a recipe that never changes — same steps, same cake, every time. A model is a recipe that learned itself from ingredients, so if the ingredients drift, the cake quietly changes too. MLOps is the extra rulebook for cooking with a recipe that can surprise you.

You may already know DevOps: the practices that let software teams ship code quickly and safely — version control, automated testing, continuous integration and delivery (CI/CD), infrastructure-as-code, monitoring. MLOps is DevOps carried over to machine learning, plus the extra headaches that come from the fact that an ML system isn’t just code — it’s code and data and a trained model, all of which can change independently.

That third axis is the whole difference. Ordinary software is deterministic: same input, same output, forever, until someone edits the code. A model’s behavior is baked in from data during training, so it can “rot” even when nobody touches the code — because the world the data described has moved on. That’s why MLOps adds concerns that classic DevOps never had to worry about:

ConcernTraditional DevOpsMLOps adds…
What you versionCodeCode plus data plus the trained model plus the experiment that produced it
What “tested” meansDoes the code do what the spec says?Is the model accurate enough on fresh, representative data? (No fixed spec — quality is statistical.)
What breaks over timeNothing, unless code changesBehavior decays on its own as real-world data drifts away from training data
Deploy artifactA binary / containerA model file (weights) and its inference code, often on specialized hardware (GPUs)
RollbackRedeploy the last good buildRedeploy the last good model version — so you must have kept it, and know it was good

The same instinct powers LLMOps — the version of this discipline aimed at large language models and the agents built on them. Whether you’re serving a small classifier you trained in-house or calling a frontier model like Claude, GPT, or Gemini through an API, the reliability questions rhyme: is it up, is it fast enough, is it still good, and can I roll back when it isn’t? This page focuses on the classic model-serving case; the agent-specific slice is covered in Production & Operations.

The core MLOps insight: a model is a living artifact, not a frozen binary. It can get worse without anyone changing a line of code — so you have to watch it, version it, and be ready to retrain it.

The ML lifecycle: data → train → deploy → monitor → retrain

☺ Like you’re 10: It’s a circle, not a finish line. Gather ingredients, bake, put the cake in the shop, taste-check every day, and when it starts going stale, go bake a fresh batch. Round and round — a model is never “done.”

MLOps is best understood as a loop, not a one-way pipeline. A model that ships is at the start of its real life, not the end. The stages:

Data collect · clean Train fit · evaluate Deploy serve · scale Monitor watch drift retrain: drift or decay triggers a fresh cycle a model is never “done” — the loop keeps turning
  1. Data. Collect, clean, label, and validate the data the model learns from. This is where most of the real work lives — see Data Engineering. Garbage in, garbage model out.
  2. Train. Fit the model and evaluate it on held-out data to estimate how well it’ll do on inputs it’s never seen. The mechanics are in Training Models; MLOps cares that this step is repeatable and tracked.
  3. Deploy. Package the trained model and put it somewhere it can answer requests — behind an API, in a batch job, or on a device. This is “serving,” the next section.
  4. Monitor. Watch the live model for slowdowns, errors, and — the sneaky one — quality decay as the world drifts. Covered below.
  5. Retrain. When monitoring says quality has slipped (or on a schedule), gather fresh data and run the loop again, then ship the new version. Back to step one.

The arrow that makes it a loop is the last one. In traditional software you might deploy and forget; in ML, deploying is when the clock starts ticking on the model’s freshness. A well-run team automates as much of this circle as possible so that “the model is drifting” leads, with minimal human toil, to “a retrained model is live.”

Model serving: getting predictions to users

☺ Like you’re 10: Once the cake recipe is perfect, how do you hand out cake? Bake-to-order the moment someone walks in (fast, one at a time), or bake a giant tray overnight for the whole school (cheaper per slice, but nobody eats until morning). Serving is choosing how the cake reaches people.

Serving (or inference serving) is running the trained model to produce predictions for real requests. The first big fork is when predictions are needed:

Real-time (online) servingBatch (offline) serving
ShapeOne request in, one answer out, right now — behind an API endpointMillions of inputs processed together on a schedule, results written to a table/store
Optimized forLatency — how fast a single answer comes backThroughput — how many predictions per hour, cheaply
ExamplesFraud check at checkout; a chatbot reply; a search rankingNightly recommendation refresh; scoring every customer for churn; embedding a whole document corpus
Feels likeBake-to-orderBake a giant tray overnight

The most common real-time pattern is to wrap the model in an HTTP API: the model loads into memory once when the server starts, then each request runs a forward pass and returns the prediction as JSON. This is exactly the shape you already use when you call a hosted model — the Claude, OpenAI, or Gemini APIs are enormous, highly optimized versions of this same “model behind an endpoint” idea.

# A real-time model server, in spirit
model = load_model("churn-v7.bin")     # loaded ONCE at startup, kept in memory

on_request(input):                     # runs PER request
    features = preprocess(input)
    score    = model.predict(features) # the forward pass — the expensive part
    return { "churn_risk": score }     # JSON back to the caller, fast

Two forces dominate real-time serving. Latency vs throughput is a constant trade: batching incoming requests together lets a GPU crunch many at once (great throughput) but makes each caller wait a moment for the batch to fill (worse latency). And hardware matters: deep models — especially large language models — run far faster on GPUs (or specialized accelerators like TPUs and various inference chips) than on ordinary CPUs, because a forward pass is mostly big matrix multiplications that those chips are built to do in parallel. Small classical models (see Classical ML) often serve happily on plain CPUs; a big deep-learning model usually needs an accelerator to hit acceptable latency.

◆ Key idea

Serving is where model quality meets engineering reality. A model that’s 1% more accurate but 10× slower or 10× pricier to run may be the wrong choice in production. The best model is the one that’s good enough and affordable enough to serve at your traffic.

Scaling & cost: serving without going broke

☺ Like you’re 10: A bakery hires more staff at lunch rush and sends them home when it’s quiet (autoscaling), uses a smaller cheaper oven when the fancy one is overkill (quantization), keeps popular cakes on the counter so it doesn’t re-bake them (caching), and grabs day-old-price oven time when it can wait (spot compute). All tricks to serve more for less.

GPUs are expensive, and traffic is spiky, so a huge part of MLOps is serving well without a runaway bill. The main levers:

These stack. A well-tuned production model might be quantized to fit more copies per GPU, autoscaled to match a daily traffic curve, front by a cache that absorbs repeat questions, with heavy batch jobs pushed onto spot compute overnight. The art is squeezing cost without quietly degrading quality or latency past what users will tolerate.

⚠ Cost is a first-class metric

Inference cost isn’t an afterthought — at scale it’s often the largest line item and the thing that decides whether a feature ships. Track cost-per-request alongside accuracy and latency from day one; a model you can’t afford to run is not in production, no matter how good it is.

Monitoring: why models “get worse” silently

☺ Like you’re 10: Nobody broke the cake recipe — but the customers changed. Last year everyone loved chocolate; this year they want vanilla, and your chocolate-only bakery is suddenly getting bad reviews without changing a thing. A model can go stale the same quiet way, so you have to keep tasting.

This is the concern that surprises people coming from ordinary software. A deployed model can degrade with zero code changes and zero bugs, purely because the live data has drifted away from what it was trained on. The failure is silent: the model keeps returning confident predictions, they’re just increasingly wrong. Monitoring is how you catch it. The main things to watch:

What to watchWhat it meansReal example
Operational healthIs it up and fast? Latency, error rate, throughput, cost.P95 latency creeping past your SLA as traffic grows
Data driftThe inputs have shifted from the training distribution.A new customer segment sends inputs the model rarely saw in training
Concept driftThe relationship between inputs and the right answer has changed.What counts as “fraud” shifts as fraudsters change tactics
Quality / model decayAccuracy on real outcomes is dropping, whatever the cause.A recommender’s click-through rate sliding month over month

Data drift and concept drift are the two flavors of the same rot. In data drift the questions change; in concept drift the correct answers change. Either way, a model trained on last year’s world is answering this year’s — and quality decays. The hard part is that you often can’t measure accuracy directly in real time, because the true answer (did this customer actually churn? was that transaction really fraud?) arrives days or weeks later, if ever. So teams watch proxies: shifts in the input distribution, drops in prediction confidence, changes in the mix of outputs — early-warning signs that ground truth, when it arrives, will look worse.

For LLMs and agents the same idea applies but the metric is fuzzier: there’s rarely a single “accuracy” number, so teams lean on evals (running the model against a curated test set and scoring it), sampled human review, and automated judges. The through-line with classic ML is identical — measure quality continuously in production, because it will not stay put. The agent-flavored version of all this lives in Production & Operations.

🎬 At the AI Academy
🐢

Timmy the Turtle: Churn model v7 is live and serving. Dashboards green — latency good, errors near zero. Now I just… watch.

🐢

Timmy the Turtle: Three weeks in — a drift alarm just fired. The input mix shifted, and accuracy on the customers whose outcomes we can now measure has slid from 91% to 83%. Nobody touched the code.

🦊

Foxy: Wait — how does a model that worked just go bad? We didn’t change anything!

🐢

Timmy the Turtle: That’s the trap. The world changed — a big new customer segment behaves nothing like our training data. The model’s frozen; reality kept moving. That’s drift. So I pull fresh, labeled data and retrain v8.

🦫

Benny the Beaver: And I’ll roll v8 out behind v7 — shadow it, compare, then flip traffic over. If it misbehaves, we roll straight back to v7. Because we kept it. Reliability by design.

Versioning & reproducibility: CI/CD for ML

☺ Like you’re 10: Every batch of cakes gets a label saying exactly which recipe, which flour, and which oven made it. So when one batch is amazing — or awful — you can make it again, or never make it again. Without labels, you’re guessing.

Because an ML system is code and data and a model, reproducibility means tracking all three together. The goal is to be able to answer, for any prediction in production: exactly which model made this, trained on which data, by which code, with which settings? If you can’t answer that, you can’t debug it, audit it, or reliably roll back. What gets versioned:

CI/CD for ML then automates the loop the way DevOps automates code deploys — but with extra gates. A push might trigger: retrain on the latest data snapshot → run the eval suite → only if quality clears a bar, register the new model version and deploy it (often gradually — canary or shadow first, then full traffic). The crucial addition over plain CI/CD is that the passing test is statistical: “the new model scores at least as well as the current one on the held-out set,” not merely “the code compiles.” A model that builds fine but scores worse should never reach users.

◆ Rule of thumb

If you can’t reproduce a model — same code, same data, same config — you can’t trust it, ship it safely, or roll it back. Version the model, the data, and the experiment, not just the code. Reproducibility is the safety net.

How this differs from Production & Operations

☺ Like you’re 10: This page is about running the bakery — keeping the ovens hot and the cakes fresh. The other page is about running the delivery robot that takes cake to customers, makes decisions on the way, and might do something silly if you’re not watching. Same spirit, different layer.

These two lessons are close cousins, and it’s worth being precise about the split so you know which to reach for. This page (MLOps) is about serving models — the training-to-serving-to-retraining loop for an ML model as a component. Production & Operations is about operating agents and LLM applications — the systems built on top of models that reason, call tools, and take actions.

MLOps (this page)Production & Ops
Unit of concernA trained model serving predictionsAn agent or LLM app taking actions
Core loopData → train → deploy → monitor → retrainPrompt/behavior → deploy → observe → evaluate → iterate
“Gets worse” meansDrift: inputs/outcomes shift from training dataRegressions from prompt, tool, or model-version changes; new failure modes
Quality signalAccuracy, drift metrics, error against ground truthEvals, human review, task success, trajectory traces
Special worriesGPUs, retraining, model registry, quantizationTool safety, prompt injection, cost per turn, guardrails

In practice they layer: a production agent often calls one or more served models (some you trained, some you rent from a provider), so a real system runs both disciplines at once. If you’re building agents, start with Building Agents and Agentic AI, operate them with Production & Operations, and treat this page as the layer beneath — how the models those agents depend on stay fast, cheap, and correct. For the security angle that cuts across both, see AI Security and Responsible AI; to see where MLOps sits in the wider toolscape, the Ecosystem and Further Reading pages point to the mainstream platforms and papers.

🦫 Benny’s workshop · 10 min

Pick any model API you can call (Claude, GPT, or Gemini all work). Send the same prompt 20 times and log the latency of each call, then send 20 different prompts and log those too. You’ll see latency vary — and if you check the provider’s pricing, you can multiply tokens by rate to estimate cost-per-call. Congratulations: you just did the two things every serving dashboard tracks — latency and cost — by hand. Now imagine watching those, plus a quality metric, for millions of calls a day. That’s the monitoring half of MLOps.

🐢 Timmy’s checkpoint

(1) Name the five stages of the ML lifecycle loop, and explain why it’s a loop rather than a line. (2) What’s the difference between real-time and batch serving, and which optimizes for latency vs throughput? (3) A model that hasn’t had a single code change starts giving worse answers — what’s the most likely cause, and what’s the difference between data drift and concept drift? (4) Why does MLOps version the data and the experiment, not just the code — and how does that make rollback possible? (5) In one sentence, how does MLOps differ from the agent-ops in Production & Operations?

Check your answers
  1. The five stages: Data → Train → Deploy → Monitor → Retrain. It’s a loop because deploying is when the clock starts on a model’s freshness, not the finish line — monitoring catches drift or decay, which triggers a fresh cycle back to data, since a model is never “done.”
  2. Real-time vs batch serving: Real-time (online) serving takes one request in and one answer out right now behind an API, and optimizes for latency — how fast a single answer comes back. Batch (offline) serving processes millions of inputs together on a schedule and optimizes for throughput — how many cheap predictions per hour.
  3. Most likely cause and drift types: The most likely cause is drift — the live data has moved away from the training data, so the model rots even with zero code changes. In data drift the inputs shift from the training distribution (the questions change); in concept drift the relationship between inputs and the right answer changes (the correct answers change).
  4. Versioning data and experiment enables rollback: An ML system is code plus data plus a trained model, so reproducibility requires tracking all three — you must be able to say exactly which model made a prediction, on which data, by which code and settings. Storing each model version in a registry (alongside its data snapshot and experiment log) is precisely what lets you redeploy the last known-good version instantly, like rolling back to v7.
  5. MLOps vs Production & Operations: MLOps is about serving and retraining a trained model as a component (data → train → deploy → monitor → retrain), whereas Production & Operations is about operating the agents and LLM apps built on top of those models that reason, call tools, and take actions.