CI/CD for ML
Tests for data schemas and model quality gates in the pipeline, canary rollout of models, rollback to the previous artifact. Same discipline as code deploys.
The mental model
CI/CD for ML is a factory line with quality gates, where the raw material is data, not just code. In ordinary software, CI answers one question — "does the code still work?" — and if the tests pass, you ship. ML has a second, sneakier input: the data. A pipeline can have perfect code and still ship a broken model because the *data* changed shape, developed nulls, or shifted distribution. So ML CI/CD adds gates the software world never needed: data-schema tests, a model-quality gate, and a promotion decision — and it ships an artifact (a trained model) that behaves probabilistically, not a binary that behaves deterministically.
The load-bearing idea interviewers listen for: **you cannot unit-test a model the way you unit-test a function.** A function has a right answer; a model has a metric on a held-out set. So the "test that must pass before deploy" is not assert output == expected, it is assert challenger.metric >= champion.metric on a frozen eval set — a quality gate, not an assertion. And because the model is stochastic and the data is alive, the deploy is not "flip it on"; it is a canary that lets a small slice of real traffic vet the new model before it owns everything, with a one-command rollback to the previous artifact always ready.
The same discipline as code deploys, applied to a thing that fails differently: code fails loudly and deterministically; models fail quietly and statistically. So the pipeline's job is to make the quiet, statistical failure loud and gated — catch bad data before training, catch a worse model before promotion, and catch a real-world regression before it owns 100% of traffic.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision