Lightning-AI / Lightning-AI/lightning-thunder
Unexpected removal of copy operations in nvfuser executor's fusion pass
@beverlylytle is already working on this.
Since Mar 26, 2025.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
When `update_aliases' is [supported](https://github.com/Lightning-AI/lightning-thunder/blob/71f89ab49288fcd54f65bd4633aac72dd72560ad/thunder/executors/nvfuserex_impl.py#L1734) in the nvfuser executor, [setting an item on a view fails](https://github.com/Lightning-AI/lightning-thunder/blob/71f89ab49288fcd54f65bd4633aac72dd72560ad/thunder/tests/test_update_aliases.py#L38) in an unexpected way. In the fusion pass on the first function in the above-mentioned test, the following 5 bound_symbol_groups are created:
```
[# x: "cuda:0 f32[2, 3]"],
[(t5,) = prims.update_aliases((x,)), y = ltorch.view(t5, (3, 2)) # y: "cuda:0 f32[3, 2]"
# y = ltorch.reshape(t5, (3, 2)) # y: "cuda:0 f32[3, 2]"
# y = prims.reshape(t5, (3, 2)) # y: "cuda:0 f32[3, 2]", (t6, t7) = prims.update_aliases((y, t5)), t2 = ltorch.getitem(t6, 0) # t2: "cuda:0 f32[2]"
# t1 = prims.slice_prim(t6, [0, 0], [1, 2], [1, 1]) # t1: "cuda:0 f32[1, 2]"
# t2 = prims.squeeze(t1, (0,)) # t2: "cuda:0 f32[2]", (_, t9, t10) = prims.update_aliases((t6, t7, t2))],
[t12 = copy_with_setitem_impl(t10, 0, 0) # t12: "cuda:0 f32[2]"],
[prims.copy_(t12, t10, grad_enabled=True)],
[return {'output': (t9,), 'flat_args': [t9]}]
```
The second to last bsym has no output, and it DCE'd away, the third to last bsym's output is not used, and so is DCE'd away. Thus, no item assignment occurs.
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.
Assessment
This issue has not been assessed yet.