Skip to content

Commit 83ec7cd

Browse files
bobrenjc93pytorchmergebot
authored andcommitted
Fix recompile reason logging (pytorch#148200)
for the following test case ``` @torch.compile(dynamic=False, backend=cnts) def fn(x, y, z): return x * y * z[0] fn(1, torch.randn(1), {0: torch.randn(1)}) fn(2, torch.randn(2), {0: torch.randn(2)}) fn(3, torch.randn(3), {0: torch.randn(3)}) fn(4, torch.randn(4), {0: torch.randn(4)}) fn(5, torch.randn(5), {0: torch.randn(5)}) ``` previously we would log ``` 0/0: L['x'] == 1 0/0: L['x'] == 1 0/0: L['x'] == 1 0/0: L['x'] == 1 ``` but after this change we now log ``` 0/0: L['x'] == 1 0/1: L['x'] == 2 0/2: L['x'] == 3 0/3: L['x'] == 4 ``` Pull Request resolved: pytorch#148200 Approved by: https://github.com/xmfan
1 parent 40b3e4a commit 83ec7cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torch/_dynamo/convert_frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ def count_args(code: CodeType) -> int:
945945
if is_recompilation(cache_size) and frame:
946946
reasons = get_and_maybe_log_recompilation_reasons(cache_entry, frame)
947947
recompile_reason = (
948-
"Unable to find recompilation reasons" if not reasons else reasons[-1]
948+
"Unable to find recompilation reasons" if not reasons else reasons[0]
949949
)
950950
metrics_context.update_outer({"recompile_reason": recompile_reason})
951951

0 commit comments

Comments
 (0)