lightning-thunder
lightning-thunder copied to clipboard
[feature request] serialization for trace objects
🚀 Feature
Would be really great to be able to serialize trace objects. That can be very beneficial for debugging, for example.
Mappings str -> Trace, Trace -> str would also be great to have.
My initial thoughts:
Probably good to start very simple:
def fn(a, b):
return a + b
tm = thunder.jit(fn)
a, b = torch.randn(2, 5)
tm(a, b)
trace = thunder.last_traces(tm)[0]
My preliminary ideas:
- traces themselves are likely not that complicated, bound symbols, proxies, and a bit of admin.
- proxies can likely be described very similar to what's going on with replace. Create a temp trace if you need for creating proxies,
- bound symbols need to do
sym.bindand find the rightsym(which they may assume to be available from thunder) - this is probably the main trick.