← all musings

The Bug That Flatters You

The worst ML bugs don't crash. They flatter you. The thorough test is the backstop. The cheap test is the tripwire. Put the tripwire first.

The most dangerous bug in machine learning doesn’t crash. It hands the model the answer.

On July 30, Hugging Face’s Transformers library turned on PyTorch’s scaled dot-product attention for T5. One side effect was that UMT5’s decoder could attend to future tokens. During training, it could peek at the answer it was supposed to predict. Nothing crashed. The bug stayed in main for almost two months. When the team later replayed those commits, a small UMT5 model running on CPU flagged the bug on every one of them.

That’s a small story. The lesson in it is bigger.

After a miss like this, everyone reaches for more coverage: bigger tests, real checkpoints, more GPUs. Transformers already has all of that. It supports over 750 model types. It runs 88,000+ CPU tests on main and 200,000+ GPU tests in a daily run. Its integration tests load real checkpoints and exercise them on real hardware. That’s the high-fidelity answer, and the team names its flaw plainly. Running all of it on every pull request would keep a lot of GPUs busy all day, which isn’t practical. So the heavy suite runs on a schedule. By the time a scheduled run finds a regression, it may already be in main.

Fidelity is the enemy of frequency. A test too expensive to run on every change is a test that runs after the damage is done. Hugging Face doesn’t throw out the expensive suite. It puts something cheap in front of it. Shrink the model. Take the real checkpoint’s configuration. Keep every kind of layer it has, but make the layers fewer and narrower. Leave the tokenizer and processor files unchanged. Publish the result once and reuse it. Run “fast integration tests” against it on a cheap CPU runner. The experimental UMT5 fixture has 66 MB of weights. The source checkpoint is 1,227 MB. Some models don’t fit on the standard GPU runners at all, and their fixtures still run on CPU.

Look at what they kept. Not size. Structure. But the small model is only one leg of the stool. A Model Integration Contract has three parts: the fixture; a usage path, meaning a runnable example of something people actually do with the model, like generating text or running a training step; and baselines, the outputs recorded from running that example and reviewed by a human. The contract holds if the usage path on the fixture still produces the baselines. Transformers already had tiny-random checkpoints. What’s new is a common recipe, and checks that go beyond loading the model and running a forward pass. That second part matters. The UMT5 bug would have passed a forward pass just fine. It got caught because label log-probabilities drifted from the reviewed baseline by 1.22 and training loss by about 0.20.

One more detail matters even more. The contract used SDPA, the default attention path. Running only the eager attention variant missed the bug. Shrinking the model was safe. Swapping the code path wasn’t. A fixture only helps if it goes through the same code as the real checkpoint.

Now the part that should bother anyone training models. The UMT5 bug is a leak. A decoder that can see the future is being given the answer. My read: a bug like that doesn’t show up as an error. It shows up as a model that seems to be learning easily. Ordinary software bugs punish you. ML bugs can flatter you. And nobody goes looking for the root cause of good news.

That flips the economics of testing. In a web app, silent failures are rare because failures make noise: crashes, 500s, angry users. In ML, the loud failures are the cheap ones. The costly ones are quiet and plausible, and they can look better than correct behavior. The only defense against a bug that flatters you is a check that ignores how good the numbers look. It asks one question, whether or not anyone suspects a problem: does the model still behave the way the contract says it should? On a PR, Hugging Face picks which contracts to run based on the files the patch changes.

Don’t oversell this, and Hugging Face doesn’t. Their own line: fixtures won’t replace full integration tests, but on PRs they give a chance to catch bugs before they reach main. The MIC job currently reports failures without blocking PRs. How many real bugs it catches on PRs, not just in replays, is an open question they list themselves. And the small model has blind spots the real one doesn’t. Both Whisper fixtures, random and overfit, missed an assisted-decoding bug that the real Whisper checkpoint exposed.

So this isn’t cheap versus thorough. It’s order of operations. The cheap check sits on the PR. The full suite sits behind it and catches what the miniature can’t see. The mistake is asking the expensive suite to do the cheap check’s job.

The stakes go up from here. Hugging Face’s post includes a section on building these contracts with agents, and that’s the right direction, with the right guardrail: the LLM drafts, it doesn’t approve, and changed expectations require human review. As agents write more of the code that lands in open-source libraries, the number of changes goes up and the human attention each one gets goes down. A daily run on expensive hardware was already struggling to keep up with a 750-model library. It will fall further behind once machines are opening the pull requests. Verification that scales with machine-written code needs a cheap first pass on each change, with the heavy suite as the backstop.

The thorough test is the backstop. The cheap test is the tripwire. Put the tripwire first.