lightning-thunder icon indicating copy to clipboard operation
lightning-thunder copied to clipboard

[feature request] serialization for trace objects

Open nikitaved opened this issue 1 year ago • 1 comments

🚀 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.

nikitaved avatar Jul 25 '24 09:07 nikitaved

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.bind and find the right sym (which they may assume to be available from thunder) - this is probably the main trick.

t-vi avatar Aug 02 '24 16:08 t-vi