Repository: pytorch
Issue: DISABLED test_reorder_peak_memory (__main__.TestOperatorReorderForPeakMemory)
Labels: module: rocm,triaged,module: flaky-tests,skipped,oncall: pt2,module: inductor

Platforms: rocm

This test was disabled because it is failing in CI. See [recent examples](https://hud.pytorch.org/flakytest?name=test_reorder_peak_memory&suite=TestOperatorReorderForPeakMemory&limit=100) and the most recent trunk [workflow logs](https://github.com/pytorch/pytorch/runs/35949205522).

Over the past 3 hours, it has been determined flaky in 3 workflow(s) with 3 failures and 3 successes.

**Debugging instructions (after clicking on the recent samples link):**
DO NOT ASSUME THINGS ARE OKAY IF THE CI IS GREEN. We now shield flaky tests from developers so CI will thus be green but it will be harder to parse the logs.
To find relevant log snippets:
1. Click on the workflow logs linked above
2. Click on the Test step of the job so that it is expanded. Otherwise, the grepping will not work.
3. Grep for `test_reorder_peak_memory`
4. There should be several instances run (as flaky tests are rerun in CI) from which you can study the logs.



<details><summary>Sample error message</summary>

```
Traceback (most recent call last):
  File "/var/lib/jenkins/pytorch/test/inductor/test_memory.py", line 71, in test_reorder_peak_memory
    .run(code)
RuntimeError: Expected to find "buf0 = " but did not find it
Searched string:
        stream0 = get_raw_stream(0)
        triton_red_fused_sum_2.run(buf4, buf6, 1, 2048, grid=grid(1), stream=stream0)
        buf1 = buf4; del buf4  # reuse
        # Topologically Sorted Source Nodes: [t2], Original ATen: [aten.mm]
        extern_kernels.mm(primals_2, primals_3, out=buf1)
        del primals_3
        buf5 = empty_strided_cuda((2048, 10), (10, 1), torch.float32)
        # Topologically Sorted Source Nodes: [t4], Original ATen: [aten.mm]
        extern_kernels.mm(buf1, primals_5, out=buf5)
        buf7 = empty_strided_cuda((3, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [sum_2], Original ATen: [aten.sum]
        stream0 = get_raw_stream(0)
        triton_red_fused_sum_3.run(buf5, buf7, 3, 6827, grid=grid(3), stream=stream0)
        del buf5
        buf9 = buf6; del buf6  # reuse
        # Topologically Sorted Source Nodes: [sum_2, add], Original ATen: [aten.sum, aten.add]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_sum_4.run(buf9, buf7, 1, 3, grid=grid(1), stream=stream0)
        del buf7
    return (buf9, primals_2, reinterpret_tensor(buf1, (1, 2048), (1, 1), 0), reinterpret_tensor(primals_5, (10, 1), (1, 10), 0), reinterpret_tensor(buf0, (10, 2048), (1, 10), 0), reinterpret_tensor(primals_4, (1, 10), (1, 1), 0), )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((1, 10), (10, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((2048, 1), (1, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((1, 1), (1, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((10, 1), (1, 1), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((1, 10), (10, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)
From CHECK: buf0 = 


To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_ROCM=1 python test/inductor/test_memory.py TestOperatorReorderForPeakMemory.test_reorder_peak_memory

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>


Test file path: `inductor/test_memory.py`

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang @naromero77amd @clee2000 @wdvr @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov