Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions test/inductor/test_max_autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,15 @@ def put(self, filename, data):
reset()
torch._inductor.codecache.PyCodeCache.clear()
self.assertEqual(num_get, 3)
# TODO: This should really be 1 but it seems like we write even
# when we find it
self.assertEqual(num_put, 4)
self.assertEqual(num_put, 1)
num_get = 0
num_put = 0
for _ in range(4):
torch.compile(f, dynamic=dynamic)(x, y)
reset()
torch._inductor.codecache.PyCodeCache.clear()
self.assertEqual(num_get, 3)
# TODO: This should really be 1 but it seems like we write even
# when we find it
self.assertEqual(num_put, 4)
self.assertEqual(num_put, 1)

def test_precompilation_threads(self):
import threading
Expand Down
11 changes: 7 additions & 4 deletions torch/_inductor/triton_heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ def load_cached_autotuning(
configs_hash: str,
configs: List[Config],
):
if best_config is None:
return None
if best_config.pop("configs_hash", None) != configs_hash:
return None

Expand Down Expand Up @@ -856,12 +858,13 @@ def cached_autotune(
with open(cache_filename) as fd:
best_config = json.loads(fd.read())
elif remote_cache is not None and remote_cache_key is not None:
best_config = remote_cache.get([remote_cache_key])
cache_outs = remote_cache.get([remote_cache_key])
cache_out = cache_outs.get(remote_cache_key, None)
best_config = json.loads(cache_out) if cache_out else None

best_config = load_cached_autotuning(best_config, configs_hash, configs)
if best_config:
best_config = load_cached_autotuning(best_config, configs_hash, configs)
if best_config:
configs = [best_config]
configs = [best_config]

def save_cache_hook(cfg, found_by_coordesc=False):
data = json.dumps(
Expand Down