Developer Tools

PyTorch Inductor PR #189206 fixes precompile entry leak on reset

A one-line fix prevents stale precompile entries from breaking caching tests.

Deep Dive

PyTorch’s Inductor compiler uses a code cache to store compiled kernels, but a subtle bug in the `reset()` method caused precompile entries to persist after reset. This broke caching-dependent tests — specifically, `test_cache_hot_load_caching_precompile` expected 2 autotune artifacts after reset but got 4, leading to an assertion failure. The root cause was that `target_code` was not being tracked in the `input_codes` tracker, so the cleanup logic missed it.

PR #189206, authored by eqy, fixes this by registering `target_code` in the `input_codes` tracker. This ensures that when the cache is reset, all related precompile entries are properly removed. The fix is minimal — a single code change — but has significant impact for developers relying on Inductor’s caching for performance. Without it, builds and test suites could accumulate stale entries, leading to unpredictable behavior. The PR was approved by williamwen42 and is now merged into the PyTorch trunk.

Key Points
  • Bug: reset() left precompile entries in cache, causing stale data
  • Assertion failure: test expected 2 autotune artifacts but got 4 after reset
  • Fix: register target_code in input_codes tracker to ensure proper cleanup

Why It Matters

Ensures cache reliability for PyTorch Inductor, preventing stale precompile entries from breaking builds and tests.

📬 Get the top 10 AI stories daily