Dynamo's recompile cache is keyed per code object, and every
torch.compile-d plain callable (any non-nn.Module, e.g. an Op instance)
shares torch's single wrapper frame. Each compiled op instance in one
pytest process therefore consumes one slot of that frame's shared
cache_size_limit (default 8): in the push-tier run the smoke-tier
compile tests in tests/ops/test_norm_ops.py (2 compiles) and
tests/ops/test_pool.py (6 compiles) filled all 8 slots before
tests/test_compile.py ran, so every full-tier test_mha_kernel_compile
case failed with FailOnRecompileLimitHit.
Fix at the test-isolation layer: add a shared isolated_dynamo fixture
(torch._dynamo.reset() before and after) in tests/conftest.py and
request it from every test that calls torch.compile. The op wrapper is
not the right layer — the exhausted frame is torch's own wrapper shared
across all compiled callables, and each individual compile is
legitimate; no per-op change can stop distinct instances from consuming
slots of that shared per-code-object cache.
tests/ops/test_elementwise_compile.py already reset dynamo around each
test; its local fixture now delegates to the shared one.
Co-Authored-By: Ibuki 🍃 — a wind born from GPTs <Ibuki-wind@users.noreply.github.com>