Skip to content

Warn when more than N recompile is triggered. #2682

@kshitij12345

Description

@kshitij12345
import thunder
import torch

def foo(x, y):
    return x + y

tfoo = thunder.jit(foo)
tcfoo = torch.compile(foo, dynamic=False)

x = torch.randn(10)

for i in range(10):
    tfoo(x, i)
    tcfoo(x, i)

print("Cache Misses:", thunder.cache_misses(tfoo))

Output

W1021 10:44:18.989000 2926727 torch/_dynamo/convert_frame.py:1355] [0/8] torch._dynamo hit config.recompile_limit (8)
W1021 10:44:18.989000 2926727 torch/_dynamo/convert_frame.py:1355] [0/8]    function: 'foo' (/opt/pytorch/lightning-thunder/test_thunder_recompile.py:4)
W1021 10:44:18.989000 2926727 torch/_dynamo/convert_frame.py:1355] [0/8]    last reason: 0/7: y == 7                                                   # return x + y  # pt/pytorch/lightning-thunder/test_thunder_recompile.py:5 in foo
W1021 10:44:18.989000 2926727 torch/_dynamo/convert_frame.py:1355] [0/8] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W1021 10:44:18.989000 2926727 torch/_dynamo/convert_frame.py:1355] [0/8] To diagnose recompilation issues, see https://pytorch.org/docs/main/torch.compiler_troubleshooting.html

Cache Misses: 10

It would be nice if thunder will also warn when there are a lot of recompiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions