Bugs that throw are easy. The expensive ones run cleanly and return plausible numbers that happen to be wrong. Two of those turned up in an empowerment-driven RL project.
The empowerment estimator was slow, so I memoised it on content-addressed snapshots of the agent's statistics. The environment is a deterministic gridworld, so identical (goal, outcome-count) tuples recur constantly and caching pays off. That gave roughly a 5× cut in computation cost.
The useful side effect: memoising a function forces you to write down exactly what it depends on. The first bug below fell out of that exercise; the second turned up separately.
One of the memoised functions sampled internally. A function that draws randomness cannot be cached: on every call after the first it returns the stale first draw instead of a fresh sample. Nothing errors. The values are in range. The run completes and the curves look like curves.
The fix was to remove caching from that function. The general rule is the point: a cache key is a claim about what the output depends on, and if the claim is wrong, the failure is silent by construction.
The experiment runner never forwarded two estimator settings from the config file to the estimator. Runs configured for one mode had been executing with the class defaults the whole time. The value was in the config; it just never reached the object that needed it, and a missing value fell back to a plausible default, so nothing complained.
That one is now a ValueError. A configuration key the code does not support should stop the run, not quietly select a different experiment from the one you asked for.
Finding a bug is only half the work. In a later, team-wide audit of the same codebase, every fix was validated by re-running and checking whether the outputs changed at all. Several of the defects produced bit-identical goal and success sequences before and after, which means they had never affected a published number. Worth knowing either way, and cheap to establish.
What I took from it:
Log distributions, not just aggregate outcomes. Degenerate behaviour hides in the mean.
A cache key is a dependency contract. Write it down and the wrong assumptions become visible.
If a parameter is supposed to matter, add a check that fails when changing it doesn't change the result.
Make silent fallbacks loud. An unsupported config should raise, not default.