pytorch / pytorch/pytorch

[Inductor] DCE breaks with fallback operators that produce aliases + mutation

Open
#166,009 0 comments 0 reactions 0 assignees View on GitHub
module: inductor oncall: pt2 triaged
Dominant language
Python
Stars
103k
Forks
29.5k
PR merge metrics
PR metrics pending

Description

### 🐛 Describe the bug

See, this following [repro](https://gist.github.com/eellison/eb2f1a2db137a020d7bd6e25a89e0251). Note that i'm not sure you can produce the same graph through typical torch.compile invocation today. I think this is an invariant of functionalization cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @zou3519

I haven't root caused this exactly yet, although the test passes if you comment out DCE. I think there are potentially a couple issues:

- At lowering time, we realize uses of aliases to a prior mutation. However, today, that doesn't incorporate aliasing from fallback nodes, which produce a new buf name. See https://github.com/pytorch/pytorch/blob/ff8be889ad799a6f3fc9c6355f648bfbcff97148/torch/_inductor/graph.py#L1030-L1042

- Clearly the scheduler does not exactly handle mutation and aliasing exactly with fallback nodes, as with the above repro.

### Versions

main

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.