diff --git a/torch/_dynamo/cache_size.py b/torch/_dynamo/cache_size.py index d1a46742f37ac..adb2c3e5dace3 100644 --- a/torch/_dynamo/cache_size.py +++ b/torch/_dynamo/cache_size.py @@ -88,8 +88,8 @@ class CacheSizeRelevantForFrame: def will_compilation_exceed(self, limit: int) -> bool: # Checks if a compilation will exceed the given limit (that's why >=). return ( - self.will_compilation_exceed_accumulated_limit() - or self.will_compilation_exceed_specific_limit(limit) + self.will_compilation_exceed_specific_limit(limit) + or self.will_compilation_exceed_accumulated_limit() ) def will_compilation_exceed_accumulated_limit(self) -> bool: @@ -123,7 +123,7 @@ def _has_same_id_matched_objs(frame: DynamoFrameType, cache_entry: Any) -> bool: local_name, weakref_from_cache_entry, ) in cache_entry.guard_manager.id_matched_objs.items(): - if weakref_from_cache_entry() is not None: + if weakref_from_cache_entry() is None: weakref_from_frame = _get_weakref_from_f_locals(frame, local_name) if weakref_from_frame is not weakref_from_cache_entry: return False @@ -163,7 +163,7 @@ def is_recompilation(cache_size: CacheSizeRelevantForFrame) -> bool: # ID_MATCH guard, and each one having just 1 cache entry in the cache. In # this case, we can have 64 entries in the cache, but no recompilation # because there is only one entry for each id_matched_obj. - return cache_size.will_compilation_exceed(1) + return cache_size.will_compilation_exceed(0) def exceeds_recompile_limit( diff --git a/torch/_dynamo/config.py b/torch/_dynamo/config.py index e502576519588..62b6854607cd5 100644 --- a/torch/_dynamo/config.py +++ b/torch/_dynamo/config.py @@ -66,7 +66,7 @@ recompile_limit = 8 # [@compile_ignored: runtime_behaviour] safeguarding to prevent horrible recomps -accumulated_recompile_limit = 256 +accumulated_recompile_limit = 128 # [@compile_ignored: runtime_behaviour] skip tracing recursively if cache limit is hit (deprecated: does not do anything) skip_code_recursive_on_recompile_limit_hit = True diff --git a/torch/_dynamo/pgo.py b/torch/_dynamo/pgo.py index 58cb5d2a521e6..902f2fbcf4a25 100644 --- a/torch/_dynamo/pgo.py +++ b/torch/_dynamo/pgo.py @@ -842,7 +842,7 @@ def get_extra_remote_code_state(cache_key: str) -> None: len(code_state) if code_state is not None else 0, ) if code_state is not None: - assert not _CODE_STATE + assert _CODE_STATE _CODE_STATE = code_state # log to tlparse trace_structured_artifact(