[Release 1.0] `FuseStates` collapse wrong edge + undefined behavior
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
Hunting for a bad write in our model we discovered that DaCe had swapped two maps order with no data dependency. This was tracked down to `FuseStates` misbehaving. While reproducing, the error was fickle, disappearing easily - we rebuild a partial reproducer showing the bug _and_ showing a determinism issue with the pass.
## Fuse States issue
The original SDFG looks like this (file attached below)

`Block_3` has `q` has an input
`Block_5` has `q` has an output
Block 3 and 5 are effectively not sharing data dependency (output of 3 is not used in 5) but the order of blocks matter since this is a write-after-read situation.
When `FuseStates` applied (see beloew) `FuseStates` produces a single Block:

instead of two:

## Lack of determinism
Using the attached [unsimplified.sdfg.txt](https://github.com/user-attachments/files/18972136/unsimplified.sdfg.txt) as the input
This simple script should reproduce the above
```python
import dace
from dace.transformation.passes.fusion_inline import FuseStates
def f():
sdfg = dace.SDFG.from_file("./unsimplified.sdfg")
ret = FuseStates().apply_pass(sdfg, {})
print(f"Fuzed state: {ret}")
return 0
if __name__ == "__main__":
f()
```
Will print 7 if the error shows *BUT* could be printing 6 if the error magically doesn't show.
Wrapping into a simple bash should show the issue
```bash
#!/bin/bash
for i in {1..10}
do
python code_dace.py
done
```
Contributor guide
Assessment
This issue has not been assessed yet.