Skip to content
Open
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: 4 additions & 4 deletions torch/_dynamo/cache_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment on lines 88 to 95

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: 🟠 [LangGraph v3] Verify that changing the order of conditions in will_compilation_exceed does not alter the intended logic due to short-circuit evaluation.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Comment on lines 163 to 169

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: 🟠 [LangGraph v3] Changing the argument from 1 to 0 in will_compilation_exceed alters the logic of the recompilation check. This could lead to incorrect behavior by allowing recompilation when it should not occur. Verify if this change aligns with the intended logic for cache management.

Expand Down
2 changes: 1 addition & 1 deletion torch/_dynamo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion torch/_dynamo/pgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down