Lightning-AI / Lightning-AI/lightning-thunder
Represent slices natively in traces
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🚀 Feature
### Motivation
Tensor slices are represented in traces as:
```
t107 = torch_slice_prim_impl(t53, [0, 0, 0, 0], [4, 32, 2048, 0], [1, 1, 1, 1]) # t107: "cuda:0 bf16[4, 32, 2048, 0]"
```
But there's no `torch_slice_prim_impl` import. And we can use Python to represent it.
This reference comes from:
https://github.com/Lightning-AI/lightning-thunder/blob/ea1d1302f4a630e3832c07dc3adfe559111ba099/thunder/executors/torchex.py#L533-L534
https://github.com/Lightning-AI/lightning-thunder/blob/ea1d1302f4a630e3832c07dc3adfe559111ba099/thunder/executors/torchex.py#L507-L517
### Pitch
Instead represent it with `__getitem__` and `slice()`:
```python
t123 = t321.__getitem__([slice(0, 3), slice(0, 5)]) # t123: "cuda:..."
```
### Alternatives
Add the `torch_slice_prim_impl` import from torchex to the trace so that it's a valid program
cc @apaz-cli @nikitaved
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the referenced sections of thunder/executors/torchex.py, especially the slice implementation and related trace handling. Compare the current torch_slice_prim_impl representation with the proposed __getitem__ and slice() form. Done means slices are emitted as valid native trace expressions, or the alternative import is explicitly implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100