Lightning-AI / Lightning-AI/lightning-thunder

trace: add cursor to for bsym insertion

Open
#1,071 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement tracing architecture transforms
Dominant language
Python
Stars
1.5k
Forks
121
PR merge metrics
No merged PRs in 30d

Description

currently bsyms are appended to the trace. for transformations, we usually have a place in mind where these should go instead.
the current way is to

```
trace.push_scope([])
out = sym(foo, bar)
...
trace.bound_symbols[i+1:i+1] = trace.pop_scope()
```

pitch: we should get a cursor to insert bsyms at a given location directly.
```
trace.set_cursor(i)
out = sym(foo, bar)
...
```

two options:
1) use context manager - pro: backward compatible con: more indentation
2) use method set_cursor - pro: simpler for new things, con: what is with things that rely on appending to the end

I would lean to option 2) , asserting when we append to bound symbols automatically and run the tests to find the call sites where this happens.

cc @apaz-cli

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the trace implementation, trace.bound_symbols, trace.push_scope, and the call sites that append or splice bound symbols. Run the relevant test suite to identify append-dependent behavior; done means a cursor can insert bound symbols at a chosen location without breaking existing append behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.