Repository: pytorch
Issue: JIT: Dropout fails codegen on the third forward passes
Labels: triaged,module: nvfuser

### 🐛 Describe the bug

Dropout in combination with an activation function causes an issue, but only under the following conditions:

1. on CUDA (CPU works)
2. the code is jitted
3. model is in evaluation mode (works in training mode)
4. during the third forward pass

```py
import torch

class MLP(torch.nn.Module):
    def __init__(self):
        super().__init__()

        self.dropout = torch.nn.Dropout(0.5)
        self.activation = torch.nn.ReLU()
        self.layers = torch.nn.ModuleList([torch.nn.Linear(1, 1) for _ in range(2)])

    def forward(self, x):
        for layer in self.layers:
            # x = self.dropout(layer(x))  # works
            # x = self.activation(layer(x))  # works
            # x = self.activation(self.activation(layer(x)))  # works

            x = self.activation(self.dropout(layer(x)))  # fails
            # x = self.dropout(self.dropout(layer(x)))  # also fails
        return x

model = torch.jit.script(MLP()).cuda()
data = torch.rand(100, 1, device="cuda")
model.eval()
for i in range(10):
    print(i)
    model(data)
```

``` sh
$ python test.py 
0
1
2
~/.cache/pypoetry/virtualenvs/maps-Z5Tpx6_g-py3.11/lib/python3.11/site-packages/torch/nn/modules/module.py:1194: UserWarning: FALLBACK path has been taken inside: runCudaFusionGroup. This is an indication that codegen Failed for some reason.
To debug try disable codegen fallback path via setting the env variable `export PYTORCH_NVFUSER_DISABLE=fallback`
 (Triggered internally at ../torch/csrc/jit/codegen/cuda/manager.cpp:331.)
  return forward_call(*input, **kwargs)
3
4
5
6
7
8
9

$ PYTORCH_NVFUSER_DISABLE=fallback python test.py 
0
1
2
Traceback (most recent call last):
  File "/projects/maps/workspace/twoertwein/test.py", line 28, in <module>
    model(data)
  File "/usr0/home/twoertwe/.cache/pypoetry/virtualenvs/maps-Z5Tpx6_g-py3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: thread_predicates_.find(tv_inp) != thread_predicates_.end() INTERNAL ASSERT FAILED at "../torch/csrc/jit/codegen/cuda/lower_thread_predicate.cpp":221, please report a bug to PyTorch. Thread predicate map was not initialized, couldn't find T1_l[ 0 ]

### Versions

Collecting environment information...
PyTorch version: 1.13.1+cu116
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 11 (bullseye) (x86_64)
GCC version: (Debian 10.2.1-6) 10.2.1 20210110
Clang version: Could not collect
CMake version: version 3.18.4
Libc version: glibc-2.31

Python version: 3.11.1 (main, Jan 23 2023, 21:04:06) [GCC 10.2.1 20210110] (64-bit runtime)
Python platform: Linux-5.13.0-51-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2080 Ti
Nvidia driver version: 470.129.06
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          32
On-line CPU(s) list:             0-31
Thread(s) per core:              2
Core(s) per socket:              8
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           63
Model name:                      Intel(R) Xeon(R) CPU E5-2640 v3 @ 2.60GHz
Stepping:                        2
CPU MHz:                         2476.493
CPU max MHz:                     3400.0000
CPU min MHz:                     1200.0000
BogoMIPS:                        5200.33
Virtualization:                  VT-x
L1d cache:                       512 KiB
L1i cache:                       512 KiB
L2 cache:                        4 MiB
L3 cache:                        40 MiB
NUMA node0 CPU(s):               0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
NUMA node1 CPU(s):               1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts md_clear flush_l1d

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.1
[pip3] torch==1.13.1+cu116
[conda] Could not collect

cc @kevinstephano @jjsjann123