The worst inference bugs do not crash. They return something shaped exactly like a correct answer, at the normal latency, with no warning in the logs, and they can sit in production for a long time before anyone can say what is wrong beyond "it feels worse".
Most of what we chase falls into a few recurring shapes:
- Silent shape mismatches. A tensor that broadcasts where it should have failed. The output stays fluent, so nothing downstream objects.
- State that leaks between requests. Cheap to introduce, expensive to find, and almost never reproducible under a single-request test.
- Precision drift between the training path and the serving path. Two implementations that agreed on the bench and diverge under real batching.
- Preprocessing skew. The serving-side transform quietly stopped matching the one the model was fit on.
Unit tests assert on structure, and all of these preserve structure. The check that actually catches them is a differential one: run the same input through the reference path and the serving path and compare, rather than asking whether the output looks reasonable. Reasonable is exactly what these bugs produce.
Keep a reference implementation that is too slow to ship and never delete it. When something feels off, the question stops being "is this wrong?" and becomes "where do these two diverge?", which is a question you can actually answer.