[dynamo]  BackendCompilerFailed: backend='inductor' raised: NetworkXUnbounded: Infinite capacity path, flow unbounded above.
Labels: triaged, oncall: pt2

### 🐛 Describe the bug

Error with attention mask in torch.nn.TransformerEncoderLayer

Easy example:

```
if __name__=="__main__":
    import torch
    model = torch.nn.TransformerEncoderLayer(
        d_model=256,
        nhead=4,
        dim_feedforward=1024,
        dropout=0.1,
        activation="gelu",
        batch_first=True,
    )

    model = torch.compile(
        model,
        dynamic=True,
        fullgraph=True,
    )

    device = 'cuda'
    model = model.cuda()

    optimizer = torch.optim.AdamW(
        model.parameters(),
        lr=1e-4,
        weight_decay=1e-5,
    )

    model.train()

    for i in range(10):
        with torch.cuda.amp.autocast(enabled=False):
            optimizer.zero_grad()
            x = torch.randn(
                10,
                2 + i * 2,
                256,
            ).cuda()
            memory_mask = torch.zeros(
                x.size(0),
                x.size(1),
                device=x.device,
            ).bool()
            res = model(
                x,
                src_key_padding_mask=memory_mask,
            )
            loss = ((res - x) ** 2).mean()

        loss.backward()
        optimizer.step()

        print(i)
```

if "src_key_padding_mask is None" than work well.

### Error logs

[2023-05-22 23:22:23,642] torch._inductor.utils: [WARNING] using triton random, expect difference from eager

0
Failed to compute min-cut on following graph:
source primals_1_in {'capacity': inf}
source primals_2_in {'capacity': inf}
source primals_3_in {'capacity': inf}
source primals_4_in {'capacity': inf}
source primals_5_in {'capacity': inf}
source primals_6_in {'capacity': inf}
source primals_7_in {'capacity': inf}
source primals_8_in {'capacity': inf}
source primals_9_in {'capacity': inf}
source primals_10_in {'capacity': inf}
source primals_11_in {'capacity': inf}
source primals_12_in {'capacity': inf}
source primals_13_in {'capacity': inf}
source primals_14_in {'capacity': inf}
source primals_15_in {'capacity': inf}
source full_like_in {'capacity': inf}
source scalar_tensor_in {'capacity': inf}
source where_in {'capacity': inf}
source permute_1_in {'capacity': inf}
source view_in {'capacity': inf}
source mm_in {'capacity': inf}
source add_in {'capacity': inf}
source sym_size_in {'capacity': inf}
source view_2_in {'capacity': inf}
source unsqueeze_in {'capacity': inf}
source permute_2_in {'capacity': inf}
source squeeze_in {'capacity': inf}
source clone_1_in {'capacity': inf}
source permute_3_in {'capacity': inf}
source permute_4_in {'capacity': inf}
source permute_5_in {'capacity': inf}
source view_7_in {'capacity': inf}
source expand_1_in {'capacity': inf}
source clone_2_in {'capacity': inf}
source view_8_in {'capacity': inf}
source view_9_in {'capacity': inf}
source view_10_in {'capacity': inf}
source view_11_in {'capacity': inf}
source sym_size_1_in {'capacity': inf}
source sym_float_in {'capacity': inf}
source mul_1_in {'capacity': inf}
source permute_6_in {'capacity': inf}
source mul_2_in {'capacity': inf}
source view_13_in {'capacity': inf}
source sym_size_2_in {'capacity': inf}
source view_14_in {'capacity': inf}
source bmm_in {'capacity': inf}
source view_15_in {'capacity': inf}
source add_1_in {'capacity': inf}
source view_16_in {'capacity': inf}
source view_17_in {'capacity': inf}
source amax_in {'capacity': inf}
source rand_like_in {'capacity': inf}
source mul_3_in {'capacity': inf}
source view_19_in {'capacity': inf}
source sym_size_3_in {'capacity': inf}
source view_20_in {'capacity': inf}
source bmm_1_in {'capacity': inf}
source view_21_in {'capacity': inf}
source view_22_in {'capacity': inf}
source permute_8_in {'capacity': inf}
source addmm_in {'capacity': inf}
source philox_seed_like_in {'capacity': inf}
source philox_rand_like_in {'capacity': inf}
source gt_1_in {'capacity': inf}
source convert_element_type_in {'capacity': inf}
source mul_6_in {'capacity': inf}
source mul_7_in {'capacity': inf}
source var_mean_in {'capacity': inf}
source permute_10_in {'capacity': inf}
source view_24_in {'capacity': inf}
source addmm_1_in {'capacity': inf}
source mul_11_in {'capacity': inf}
source mul_13_in {'capacity': inf}
source sym_size_4_in {'capacity': inf}
source add_6_in {'capacity': inf}
source philox_rand_like_1_in {'capacity': inf}
source gt_2_in {'capacity': inf}
source convert_element_type_1_in {'capacity': inf}
source permute_11_in {'capacity': inf}
source sym_size_5_in {'capacity': inf}
source view_26_in {'capacity': inf}
source addmm_2_in {'capacity': inf}
source view_27_in {'capacity': inf}
source add_7_in {'capacity': inf}
source philox_rand_like_2_in {'capacity': inf}
source gt_3_in {'capacity': inf}
source convert_element_type_2_in {'capacity': inf}
source mul_21_in {'capacity': inf}
source mul_22_in {'capacity': inf}
source var_mean_1_in {'capacity': inf}
source add_10_in {'capacity': inf}
primals_1_in primals_1_out {'capacity': 1266556}
primals_1_out permute_1_in {'capacity': inf}
permute_1_in permute_1_out {'capacity': 1151415}
primals_2_in primals_2_out {'capacity': 7967}
primals_2_out add_in {'capacity': inf}
add_in add_out {'capacity': 579488}
primals_3_in primals_3_out {'capacity': 317194}
primals_3_out permute_8_in {'capacity': inf}
permute_8_in permute_8_out {'capacity': 288358}
primals_4_in primals_4_out {'capacity': 1649}
primals_4_out addmm_in {'capacity': inf}
addmm_in addmm_out {'capacity': 59969}
primals_5_in primals_5_out {'capacity': 1268776}
primals_5_out permute_10_in {'capacity': inf}
permute_10_in permute_10_out {'capacity': 1153433}
primals_6_in primals_6_out {'capacity': 5451}
primals_6_out addmm_1_in {'capacity': inf}
addmm_1_in addmm_1_out {'capacity': 198246}
primals_7_in primals_7_out {'capacity': 1268776}
primals_7_out permute_11_in {'capacity': inf}
permute_11_in permute_11_out {'capacity': 1153433}
primals_8_in primals_8_out {'capacity': 2195}
primals_8_out addmm_2_in {'capacity': inf}
addmm_2_in addmm_2_out {'capacity': 79819}
primals_9_in primals_9_out {'capacity': 1126}
primals_9_out mul_9_in {'capacity': inf}
primals_9_out mul_44_in {'capacity': inf}
mul_9_in mul_9_out {'capacity': 109034}
mul_44_in sink {'capacity': inf}
primals_10_in primals_10_out {'capacity': 1362}
primals_10_out add_4_in {'capacity': inf}
add_4_in add_4_out {'capacity': 99122}
primals_11_in primals_11_out {'capacity': 1126}
primals_11_out mul_24_in {'capacity': inf}
primals_11_out mul_26_in {'capacity': inf}
mul_24_in mul_24_out {'capacity': 99122}
mul_26_in sink {'capacity': inf}
primals_12_in primals_12_out {'capacity': 1239}
primals_12_out add_10_in {'capacity': inf}
add_10_in add_10_out {'capacity': 45056}
primals_13_in primals_13_out {'capacity': 1}
primals_13_out mul_in {'capacity': inf}
primals_13_out view_1_in {'capacity': inf}
primals_13_out view_2_in {'capacity': inf}
primals_13_out view_3_in {'capacity': inf}
primals_13_out view_4_in {'capacity': inf}
primals_13_out view_5_in {'capacity': inf}
primals_13_out view_7_in {'capacity': inf}
primals_13_out view_8_in {'capacity': inf}
primals_13_out view_9_in {'capacity': inf}
primals_13_out view_10_in {'capacity': inf}
primals_13_out view_11_in {'capacity': inf}
primals_13_out view_12_in {'capacity': inf}
primals_13_out expand_2_in {'capacity': inf}
primals_13_out view_13_in {'capacity': inf}
primals_13_out expand_3_in {'capacity': inf}
primals_13_out view_14_in {'capacity': inf}
primals_13_out view_15_in {'capacity': inf}
primals_13_out view_16_in {'capacity': inf}
primals_13_out view_17_in {'capacity': inf}
primals_13_out expand_4_in {'capacity': inf}
primals_13_out view_19_in {'capacity': inf}
primals_13_out expand_5_in {'capacity': inf}
primals_13_out view_20_in {'capacity': inf}
primals_13_out view_21_in {'capacity': inf}
primals_13_out mul_5_in {'capacity': inf}
primals_13_out view_23_in {'capacity': inf}
primals_13_out view_25_in {'capacity': inf}
primals_13_out mul_14_in {'capacity': inf}
primals_13_out view_33_in {'capacity': inf}
primals_13_out view_36_in {'capacity': inf}
primals_13_out view_37_in {'capacity': inf}
primals_13_out view_38_in {'capacity': inf}
primals_13_out view_39_in {'capacity': inf}
primals_13_out view_40_in {'capacity': inf}
primals_13_out view_42_in {'capacity': inf}
primals_13_out view_43_in {'capacity': inf}
primals_13_out view_45_in {'capacity': inf}
primals_13_out view_46_in {'capacity': inf}
primals_13_out view_47_in {'capacity': inf}
primals_13_out view_48_in {'capacity': inf}
primals_13_out view_49_in {'capacity': inf}
primals_13_out view_50_in {'capacity': inf}
primals_13_out view_51_in {'capacity': inf}
primals_13_out view_52_in {'capacity': inf}
primals_13_out full_in {'capacity': inf}
primals_13_out view_53_in {'capacity': inf}
mul_in mul_out {'capacity': 1}
view_1_in view_1_out {'capacity': 148684}
view_2_in view_2_out {'capacity': 526808}
view_3_in view_3_out {'capacity': 49561}
view_4_in view_4_out {'capacity': 49561}
view_5_in view_5_out {'capacity': 49561}
view_7_in view_7_out {'capacity': 912}
view_8_in view_8_out {'capacity': 2742}
view_9_in view_9_out {'capacity': 2494}
view_10_in view_10_out {'capacity': 119938}
view_11_in view_11_out {'capacity': 131932}
view_12_in view_12_out {'capacity': 109034}
expand_2_in expand_2_out {'capacity': 99122}
view_13_in view_13_out {'capacity': 45056}
expand_3_in expand_3_out {'capacity': 99122}
view_14_in view_14_out {'capacity': 45056}
view_15_in view_15_out {'capacity': 9976}
view_16_in view_16_out {'capacity': 8244}
view_17_in view_17_out {'capacity': 7496}
expand_4_in expand_4_out {'capacity': 6194}
view_19_in view_19_out {'capacity': 2816}
expand_5_in expand_5_out {'capacity': 99122}
view_20_in view_20_out {'capacity': 45056}
view_21_in view_21_out {'capacity': 119938}
mul_5_in mul_5_out {'capacity': 1}
view_23_in view_23_out {'capacity': 54517}
view_25_in view_25_out {'capacity': 180224}
mul_14_in mul_14_out {'capacity': 1}
view_33_in sink {'capacity': inf}
view_36_in sink {'capacity': inf}
view_37_in sink {'capacity': inf}
view_38_in sink {'capacity': inf}
view_39_in sink {'capacity': inf}
view_40_in sink {'capacity': inf}
view_42_in sink {'capacity': inf}
view_43_in sink {'capacity': inf}
view_45_in sink {'capacity': inf}
view_46_in sink {'capacity': inf}
view_47_in sink {'capacity': inf}
view_48_in sink {'capacity': inf}
view_49_in sink {'capacity': inf}
view_50_in sink {'capacity': inf}
view_51_in sink {'capacity': inf}
view_52_in sink {'capacity': inf}
full_in full_out {'capacity': 135168}
view_53_in sink {'capacity': inf}
primals_14_in primals_14_out {'capacity': 59969}
primals_14_out permute_in {'capacity': inf}
primals_14_out add_2_in {'capacity': inf}
permute_in permute_out {'capacity': 109034}
add_2_in add_2_out {'capacity': 109034}
primals_15_in primals_15_out {'capacity': 138}
primals_15_out full_like_in {'capacity': inf}
primals_15_out where_in {'capacity': inf}
full_like_in full_like_out {'capacity': 1104}
where_in where_out {'capacity': 1004}
tangents_1_in sink {'capacity': inf}
full_like_out where_in {'capacity': inf}
scalar_tensor_in scalar_tensor_out {'capacity': 26}
scalar_tensor_out where_in {'capacity': inf}
where_out view_7_in {'capacity': inf}
permute_out clone_in {'capacity': inf}
clone_in clone_out {'capacity': 99122}
permute_1_out mm_in {'capacity': inf}
mm_in mm_out {'capacity': 163553}
clone_out view_in {'capacity': inf}
view_in view_out {'capacity': 45056}
mul_out view_in {'capacity': inf}
view_out mm_in {'capacity': inf}
view_out sym_size_10_in {'capacity': inf}
view_out mm_7_in {'capacity': inf}
sym_size_10_in sym_size_10_out {'capacity': 1}
mm_7_in sink {'capacity': inf}
mm_out view_1_in {'capacity': inf}
view_1_out add_in {'capacity': inf}
view_1_out sym_size_in {'capacity': inf}
sym_size_in sym_size_out {'capacity': 1}
add_out view_2_in {'capacity': inf}
sym_size_out view_2_in {'capacity': inf}
sym_size_out view_50_in {'capacity': inf}
sym_size_out view_51_in {'capacity': inf}
sym_size_out view_52_in {'capacity': inf}
sym_size_out full_in {'capacity': inf}
sym_size_out view_53_in {'capacity': inf}
view_2_out unsqueeze_in {'capacity': inf}
unsqueeze_in unsqueeze_out {'capacity': 478916}
unsqueeze_out permute_2_in {'capacity': inf}
permute_2_in permute_2_out {'capacity': 435378}
permute_2_out squeeze_in {'capacity': inf}
squeeze_in squeeze_out {'capacity': 395798}
squeeze_out clone_1_in {'capacity': inf}
clone_1_in clone_1_out {'capacity': 359816}
clone_1_out select_in {'capacity': inf}
clone_1_out select_1_in {'capacity': inf}
clone_1_out select_2_in {'capacity': inf}
select_in select_out {'capacity': 109034}
select_1_in select_1_out {'capacity': 109034}
select_2_in select_2_out {'capacity': 109034}
select_out view_3_in {'capacity': inf}
select_1_out view_4_in {'capacity': inf}
select_2_out view_5_in {'capacity': inf}
view_3_out permute_3_in {'capacity': inf}
view_3_out sym_size_1_in {'capacity': inf}
permute_3_in permute_3_out {'capacity': 131932}
sym_size_1_in sym_size_1_out {'capacity': 1}
permute_3_out view_10_in {'capacity': inf}
view_4_out permute_4_in {'capacity': inf}
view_4_out sym_size_2_in {'capacity': inf}
permute_4_in permute_4_out {'capacity': 145126}
sym_size_2_in sym_size_2_out {'capacity': 1}
permute_4_out view_11_in {'capacity': inf}
view_5_out permute_5_in {'capacity': inf}
view_5_out sym_size_3_in {'capacity': inf}
permute_5_in permute_5_out {'capacity': 119938}
sym_size_3_in sym_size_3_out {'capacity': 1}
permute_5_out view_12_in {'capacity': inf}
view_7_out expand_1_in {'capacity': inf}
expand_1_in expand_1_out {'capacity': 3318}
expand_1_out clone_2_in {'capacity': inf}
clone_2_in clone_2_out {'capacity': 3018}
clone_2_out view_8_in {'capacity': inf}
view_8_out view_9_in {'capacity': inf}
view_9_out add_1_in {'capacity': inf}
add_1_in add_1_out {'capacity': 9070}
view_10_out mul_1_in {'capacity': inf}
mul_1_in mul_1_out {'capacity': 109034}
view_11_out permute_6_in {'capacity': inf}
permute_6_in permute_6_out {'capacity': 119938}
view_12_out expand_5_in {'capacity': inf}
sym_size_1_out sym_float_in {'capacity': inf}
sym_size_1_out expand_2_in {'capacity': inf}
sym_size_1_out view_13_in {'capacity': inf}
sym_size_1_out view_46_in {'capacity': inf}
sym_size_1_out view_49_in {'capacity': inf}
sym_float_in sym_float_out {'capacity': inf}
sym_float_out pow_1_in {'capacity': inf}
pow_1_in pow_1_out {'capacity': inf}
pow_1_out truediv_in {'capacity': inf}
truediv_in truediv_out {'capacity': inf}
truediv_out pow_2_in {'capacity': inf}
pow_2_in pow_2_out {'capacity': inf}
pow_2_out mul_1_in {'capacity': inf}
pow_2_out mul_2_in {'capacity': inf}
pow_2_out mul_56_in {'capacity': inf}
pow_2_out mul_57_in {'capacity': inf}
mul_2_in mul_2_out {'capacity': 109034}
mul_56_in sink {'capacity': inf}
mul_57_in sink {'capacity': inf}
mul_1_out expand_2_in {'capacity': inf}
permute_6_out mul_2_in {'capacity': inf}
mul_2_out expand_3_in {'capacity': inf}
expand_2_out view_13_in {'capacity': inf}
view_13_out bmm_in {'capacity': inf}
view_13_out permute_28_in {'capacity': inf}
bmm_in bmm_out {'capacity': 5487}
permute_28_in permute_28_out {'capacity': 45056}
sym_size_2_out expand_3_in {'capacity': inf}
sym_size_2_out view_14_in {'capacity': inf}
sym_size_2_out view_45_in {'capacity': inf}
sym_size_2_out view_48_in {'capacity': inf}
expand_3_out view_14_in {'capacity': inf}
view_14_out bmm_in {'capacity': inf}
view_14_out permute_29_in {'capacity': inf}
permute_29_in permute_29_out {'capacity': 45056}
bmm_out view_15_in {'capacity': inf}
view_15_out add_1_in {'capacity': inf}
add_1_out view_16_in {'capacity': inf}
view_16_out view_17_in {'capacity': inf}
view_17_out amax_in {'capacity': inf}
view_17_out sub_in {'capacity': inf}
amax_in amax_out {'capacity': 1874}
sub_in sub_out {'capacity': 6814}
amax_out sub_in {'capacity': inf}
sub_out exp_in {'capacity': inf}
exp_in exp_out {'capacity': 6194}
exp_out sum_1_in {'capacity': inf}
exp_out div_in {'capacity': inf}
sum_1_in sum_1_out {'capacity': 1548}
div_in div_out {'capacity': 5632}
sum_1_out div_in {'capacity': inf}
div_out rand_like_in {'capacity': inf}
div_out mul_3_in {'capacity': inf}
div_out mul_54_in {'capacity': inf}
div_out mul_55_in {'capacity': inf}
rand_like_in rand_like_out {'capacity': 6194}
mul_3_in mul_3_out {'capacity': 7496}
mul_54_in sink {'capacity': inf}
mul_55_in sink {'capacity': inf}
rand_like_out gt_in {'capacity': inf}
gt_in gt_out {'capacity': 1408}
gt_out mul_3_in {'capacity': inf}
gt_out convert_element_type_6_in {'capacity': inf}
convert_element_type_6_in convert_element_type_6_out {'capacity': 5632}
mul_3_out mul_4_in {'capacity': inf}
mul_4_in mul_4_out {'capacity': 6814}
mul_4_out expand_4_in {'capacity': inf}
expand_4_out view_19_in {'capacity': inf}
view_19_out bmm_1_in {'capacity': inf}
view_19_out permute_26_in {'capacity': inf}
bmm_1_in bmm_1_out {'capacity': 65966}
permute_26_in permute_26_out {'capacity': 2816}
sym_size_3_out expand_5_in {'capacity': inf}
sym_size_3_out view_20_in {'capacity': inf}
sym_size_3_out view_21_in {'capacity': inf}
sym_size_3_out view_36_in {'capacity': inf}
sym_size_3_out view_37_in {'capacity': inf}
sym_size_3_out view_38_in {'capacity': inf}
sym_size_3_out view_47_in {'capacity': inf}
expand_5_out view_20_in {'capacity': inf}
view_20_out bmm_1_in {'capacity': inf}
view_20_out permute_27_in {'capacity': inf}
permute_27_in permute_27_out {'capacity': 45056}
bmm_1_out view_21_in {'capacity': inf}
view_21_out permute_7_in {'capacity': inf}
permute_7_in permute_7_out {'capacity': 109034}
permute_7_out clone_3_in {'capacity': inf}
clone_3_in clone_3_out {'capacity': 99122}
clone_3_out view_22_in {'capacity': inf}
view_22_in view_22_out {'capacity': 45056}
mul_5_out view_22_in {'capacity': inf}
mul_5_out view_24_in {'capacity': inf}
view_24_in view_24_out {'capacity': 45056}
view_22_out addmm_in {'capacity': inf}
view_22_out sym_size_8_in {'capacity': inf}
view_22_out mm_6_in {'capacity': inf}
sym_size_8_in sym_size_8_out {'capacity': 1}
mm_6_in sink {'capacity': inf}
permute_8_out addmm_in {'capacity': inf}
permute_8_out permute_21_in {'capacity': inf}
permute_21_in permute_21_out {'capacity': 288358}
addmm_out view_23_in {'capacity': inf}
view_23_out permute_9_in {'capacity': inf}
view_23_out sym_size_4_in {'capacity': inf}
permute_9_in permute_9_out {'capacity': 49561}
sym_size_4_in sym_size_4_out {'capacity': 1}
permute_9_out philox_seed_like_in {'capacity': inf}
permute_9_out philox_rand_like_in {'capacity': inf}
permute_9_out mul_6_in {'capacity': inf}
philox_seed_like_in philox_seed_like_out {'capacity': 4}
philox_rand_like_in philox_rand_like_out {'capacity': 87801}
mul_6_in mul_6_out {'capacity': 131932}
philox_seed_like_out philox_rand_like_in {'capacity': inf}
philox_seed_like_out philox_rand_like_1_in {'capacity': inf}
philox_seed_like_out philox_rand_like_2_in {'capacity': inf}
philox_seed_like_out philox_rand_like_3_in {'capacity': inf}
philox_seed_like_out philox_rand_like_4_in {'capacity': inf}
philox_seed_like_out philox_rand_like_5_in {'capacity': inf}
philox_rand_like_1_in philox_rand_like_1_out {'capacity': 290252}
philox_rand_like_2_in philox_rand_like_2_out {'capacity': 87801}
philox_rand_like_3_in sink {'capacity': inf}
philox_rand_like_4_in sink {'capacity': inf}
philox_rand_like_5_in sink {'capacity': inf}
philox_rand_like_out gt_1_in {'capacity': inf}
gt_1_in gt_1_out {'capacity': 39908}
gt_1_out convert_element_type_in {'capacity': inf}
convert_element_type_in convert_element_type_out {'capacity': 145126}
convert_element_type_out mul_6_in {'capacity': inf}
mul_6_out mul_7_in {'capacity': inf}
mul_7_in mul_7_out {'capacity': 119938}
mul_7_out add_2_in {'capacity': inf}
add_2_out var_mean_in {'capacity': inf}
add_2_out sub_1_in {'capacity': inf}
var_mean_in var_mean_out {'capacity': inf}
sub_1_in sub_1_out {'capacity': 99122}
var_mean_out getitem_in {'capacity': inf}
var_mean_out getitem_1_in {'capacity': inf}
getitem_in getitem_out {'capacity': 424}
getitem_1_in getitem_1_out {'capacity': 424}
getitem_out add_3_in {'capacity': inf}
add_3_in add_3_out {'capacity': 386}
getitem_1_out sub_1_in {'capacity': inf}
add_3_out rsqrt_in {'capacity': inf}
rsqrt_in rsqrt_out {'capacity': 352}
rsqrt_out mul_8_in {'capacity': inf}
rsqrt_out div_2_in {'capacity': inf}
mul_8_in mul_8_out {'capacity': 90112}
div_2_in div_2_out {'capacity': 352}
sub_1_out mul_8_in {'capacity': inf}
mul_8_out mul_9_in {'capacity': inf}
mul_8_out mul_46_in {'capacity': inf}
mul_8_out mul_47_in {'capacity': inf}
mul_8_out mul_49_in {'capacity': inf}
mul_46_in sink {'capacity': inf}
mul_47_in sink {'capacity': inf}
mul_49_in sink {'capacity': inf}
mul_9_out add_4_in {'capacity': inf}
add_4_out view_24_in {'capacity': inf}
add_4_out add_8_in {'capacity': inf}
add_8_in add_8_out {'capacity': 109034}
permute_10_out addmm_1_in {'capacity': inf}
permute_10_out permute_16_in {'capacity': inf}
permute_16_in permute_16_out {'capacity': 1153433}
view_24_out addmm_1_in {'capacity': inf}
view_24_out sym_size_7_in {'capacity': inf}
view_24_out mm_4_in {'capacity': inf}
sym_size_7_in sym_size_7_out {'capacity': 1}
mm_4_in sink {'capacity': inf}
addmm_1_out view_25_in {'capacity': inf}
view_25_out mul_11_in {'capacity': inf}
view_25_out mul_12_in {'capacity': inf}
view_25_out sym_size_5_in {'capacity': inf}
view_25_out mul_38_in {'capacity': inf}
view_25_out mul_41_in {'capacity': inf}
mul_11_in mul_11_out {'capacity': 527730}
mul_12_in mul_12_out {'capacity': 436142}
sym_size_5_in sym_size_5_out {'capacity': 1}
mul_38_in mul_38_out {'capacity': 360448}
mul_41_in mul_41_out {'capacity': 360448}
mul_11_out mul_13_in {'capacity': inf}
mul_13_in mul_13_out {'capacity': 239878}
mul_12_out erf_in {'capacity': inf}
erf_in erf_out {'capacity': 396492}
erf_out add_5_in {'capacity': inf}
add_5_in add_5_out {'capacity': 360448}
add_5_out mul_13_in {'capacity': inf}
add_5_out mul_37_in {'capacity': inf}
mul_37_in mul_37_out {'capacity': 360448}
mul_13_out philox_rand_like_1_in {'capacity': inf}
mul_13_out mul_16_in {'capacity': inf}
mul_16_in mul_16_out {'capacity': 436142}
sym_size_4_out mul_14_in {'capacity': inf}
mul_14_out mul_15_in {'capacity': inf}
mul_15_in mul_15_out {'capacity': 1}
mul_15_out add_6_in {'capacity': inf}
add_6_in add_6_out {'capacity': 1}
add_6_out philox_rand_like_1_in {'capacity': inf}
add_6_out add_7_in {'capacity': inf}
add_6_out philox_rand_like_4_in {'capacity': inf}
add_7_in add_7_out {'capacity': 1}
philox_rand_like_1_out gt_2_in {'capacity': inf}
gt_2_in gt_2_out {'capacity': 131932}
gt_2_out convert_element_type_1_in {'capacity': inf}
convert_element_type_1_in convert_element_type_1_out {'capacity': 479756}
convert_element_type_1_out mul_16_in {'capacity': inf}
mul_16_out mul_17_in {'capacity': inf}
mul_17_in mul_17_out {'capacity': 396492}
mul_17_out view_26_in {'capacity': inf}
view_26_in view_26_out {'capacity': 180224}
permute_11_out addmm_2_in {'capacity': inf}
permute_11_out permute_12_in {'capacity': inf}
permute_12_in permute_12_out {'capacity': 1153433}
sym_size_5_out mul_18_in {'capacity': inf}
sym_size_5_out view_27_in {'capacity': inf}
sym_size_5_out view_30_in {'capacity': inf}
mul_18_in mul_18_out {'capacity': 1}
view_27_in view_27_out {'capacity': 72563}
view_30_in sink {'capacity': inf}
mul_18_out view_26_in {'capacity': inf}
mul_18_out mul_20_in {'capacity': inf}
mul_20_in mul_20_out {'capacity': 1}
view_26_out addmm_2_in {'capacity': inf}
view_26_out sym_size_6_in {'capacity': inf}
view_26_out mm_2_in {'capacity': inf}
sym_size_6_in sym_size_6_out {'capacity': 1}
mm_2_in sink {'capacity': inf}
addmm_2_out view_27_in {'capacity': inf}
view_27_out philox_rand_like_2_in {'capacity': inf}
view_27_out mul_21_in {'capacity': inf}
mul_21_in mul_21_out {'capacity': 131932}
mul_20_out add_7_in {'capacity': inf}
add_7_out philox_rand_like_2_in {'capacity': inf}
add_7_out philox_rand_like_3_in {'capacity': inf}
philox_rand_like_2_out gt_3_in {'capacity': inf}
gt_3_in gt_3_out {'capacity': 39908}
gt_3_out convert_element_type_2_in {'capacity': inf}
convert_element_type_2_in convert_element_type_2_out {'capacity': 145126}
convert_element_type_2_out mul_21_in {'capacity': inf}
mul_21_out mul_22_in {'capacity': inf}
mul_22_in mul_22_out {'capacity': 119938}
mul_22_out add_8_in {'capacity': inf}
add_8_out var_mean_1_in {'capacity': inf}
add_8_out sub_2_in {'capacity': inf}
var_mean_1_in var_mean_1_out {'capacity': inf}
sub_2_in sub_2_out {'capacity': 99122}
var_mean_1_out getitem_2_in {'capacity': inf}
var_mean_1_out getitem_3_in {'capacity': inf}
getitem_2_in getitem_2_out {'capacity': 424}
getitem_3_in getitem_3_out {'capacity': 424}
getitem_2_out add_9_in {'capacity': inf}
add_9_in add_9_out {'capacity': 386}
getitem_3_out sub_2_in {'capacity': inf}
add_9_out rsqrt_1_in {'capacity': inf}
rsqrt_1_in rsqrt_1_out {'capacity': 352}
rsqrt_1_out mul_23_in {'capacity': inf}
rsqrt_1_out div_1_in {'capacity': inf}
mul_23_in mul_23_out {'capacity': 90112}
div_1_in div_1_out {'capacity': 352}
sub_2_out mul_23_in {'capacity': inf}
mul_23_out mul_24_in {'capacity': inf}
mul_23_out mul_28_in {'capacity': inf}
mul_23_out mul_29_in {'capacity': inf}
mul_23_out mul_31_in {'capacity': inf}
mul_28_in sink {'capacity': inf}
mul_29_in sink {'capacity': inf}
mul_31_in sink {'capacity': inf}
mul_24_out add_10_in {'capacity': inf}
add_10_out output_in {'capacity': inf}
mul_27_in sink {'capacity': inf}
sum_2_in sink {'capacity': inf}
sum_3_in sink {'capacity': inf}
sub_4_in sink {'capacity': inf}
sub_5_in sink {'capacity': inf}
div_1_out mul_30_in {'capacity': inf}
mul_30_in sink {'capacity': inf}
sum_4_in sink {'capacity': inf}
sum_5_in sink {'capacity': inf}
gt_4_in sink {'capacity': inf}
convert_element_type_3_in sink {'capacity': inf}
mul_32_in sink {'capacity': inf}
mul_33_in sink {'capacity': inf}
sym_size_6_out view_28_in {'capacity': inf}
view_28_in sink {'capacity': inf}
permute_12_out mm_1_in {'capacity': inf}
mm_1_in sink {'capacity': inf}
permute_13_in sink {'capacity': inf}
permute_14_in sink {'capacity': inf}
sum_6_in sink {'capacity': inf}
view_29_in sink {'capacity': inf}
permute_15_in sink {'capacity': inf}
gt_5_in sink {'capacity': inf}
convert_element_type_4_in sink {'capacity': inf}
mul_34_in sink {'capacity': inf}
mul_35_in sink {'capacity': inf}
mul_37_out add_12_in {'capacity': inf}
add_12_in add_12_out {'capacity': 360448}
mul_38_out mul_39_in {'capacity': inf}
mul_39_in mul_39_out {'capacity': 360448}
mul_39_out exp_1_in {'capacity': inf}
exp_1_in exp_1_out {'capacity': 360448}
exp_1_out mul_40_in {'capacity': inf}
mul_40_in mul_40_out {'capacity': 360448}
mul_40_out mul_41_in {'capacity': inf}
mul_41_out add_12_in {'capacity': inf}
add_12_out mul_42_in {'capacity': inf}
mul_42_in sink {'capacity': inf}
sym_size_7_out view_31_in {'capacity': inf}
view_31_in sink {'capacity': inf}
permute_16_out mm_3_in {'capacity': inf}
mm_3_in sink {'capacity': inf}
permute_17_in sink {'capacity': inf}
permute_18_in sink {'capacity': inf}
sum_7_in sink {'capacity': inf}
view_32_in sink {'capacity': inf}
add_13_in sink {'capacity': inf}
permute_19_in sink {'capacity': inf}
mul_45_in sink {'capacity': inf}
sum_8_in sink {'capacity': inf}
sum_9_in sink {'capacity': inf}
sub_7_in sink {'capacity': inf}
sub_8_in sink {'capacity': inf}
div_2_out mul_48_in {'capacity': inf}
mul_48_in sink {'capacity': inf}
sum_10_in sink {'capacity': inf}
sum_11_in sink {'capacity': inf}
gt_6_in sink {'capacity': inf}
convert_element_type_5_in sink {'capacity': inf}
mul_50_in sink {'capacity': inf}
mul_51_in sink {'capacity': inf}
permute_20_in sink {'capacity': inf}
clone_4_in sink {'capacity': inf}
sym_size_8_out view_34_in {'capacity': inf}
view_34_in sink {'capacity': inf}
permute_21_out mm_5_in {'capacity': inf}
mm_5_in sink {'capacity': inf}
permute_22_in sink {'capacity': inf}
permute_23_in sink {'capacity': inf}
sum_12_in sink {'capacity': inf}
view_35_in sink {'capacity': inf}
permute_24_in sink {'capacity': inf}
permute_25_in sink {'capacity': inf}
permute_26_out bmm_2_in {'capacity': inf}
bmm_2_in sink {'capacity': inf}
permute_27_out bmm_3_in {'capacity': inf}
bmm_3_in sink {'capacity': inf}
convert_element_type_6_out mul_52_in {'capacity': inf}
mul_52_in mul_52_out {'capacity': 5632}
mul_52_out mul_53_in {'capacity': inf}
mul_53_in sink {'capacity': inf}
clone_5_in sink {'capacity': inf}
sum_13_in sink {'capacity': inf}
sub_9_in sink {'capacity': inf}
clone_6_in sink {'capacity': inf}
sym_size_9_in sink {'capacity': inf}
permute_28_out bmm_4_in {'capacity': inf}
bmm_4_in sink {'capacity': inf}
permute_29_out bmm_5_in {'capacity': inf}
bmm_5_in sink {'capacity': inf}
permute_30_in sink {'capacity': inf}
permute_31_in sink {'capacity': inf}
clone_7_in sink {'capacity': inf}
permute_32_in sink {'capacity': inf}
permute_33_in sink {'capacity': inf}
clone_8_in sink {'capacity': inf}
full_out select_scatter_in {'capacity': inf}
full_out select_scatter_1_in {'capacity': inf}
full_out select_scatter_2_in {'capacity': inf}
select_scatter_in sink {'capacity': inf}
select_scatter_1_in sink {'capacity': inf}
select_scatter_2_in sink {'capacity': inf}
add_14_in sink {'capacity': inf}
add_15_in sink {'capacity': inf}
unsqueeze_1_in sink {'capacity': inf}
permute_34_in sink {'capacity': inf}
squeeze_1_in sink {'capacity': inf}
clone_9_in sink {'capacity': inf}
sum_14_in sink {'capacity': inf}
view_54_in sink {'capacity': inf}
sym_size_10_out view_55_in {'capacity': inf}
view_55_in sink {'capacity': inf}
permute_35_in sink {'capacity': inf}
permute_36_in sink {'capacity': inf}
permute_37_in sink {'capacity': inf}

---------------------------------------------------------------------------
BackendCompilerFailed                     Traceback (most recent call last)
Cell In[4], line 43
     33     x = torch.randn(
     34         10, 
     35         2 + i*2, 
     36         256, 
     37     ).cuda()
     38     memory_mask = torch.zeros(
     39         x.size(0), 
     40         x.size(1), 
     41         device=x.device,
     42     ).bool()
---> 43     res = model(
     44         x, 
     45         src_key_padding_mask=memory_mask,
     46     )
     47     loss = ((res - x)**2).mean()
     49 loss.backward()

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/nn/modules/module.py:1502, in Module._wrapped_call_impl(self, *args, **kwargs)
   1500     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1501 else:
-> 1502     return self._call_impl(*args, **kwargs)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/nn/modules/module.py:1511, in Module._call_impl(self, *args, **kwargs)
   1506 # If we don't have any hooks, we want to skip the rest of the logic in
   1507 # this function, and just call forward.
   1508 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1509         or _global_backward_pre_hooks or _global_backward_hooks
   1510         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1511     return forward_call(*args, **kwargs)
   1512 # Do not call functions when jit is used
   1513 full_backward_hooks, non_full_backward_hooks = [], []

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py:287, in _TorchDynamoContext.__call__.<locals>._fn(*args, **kwargs)
    285 dynamic_ctx.__enter__()
    286 try:
--> 287     return fn(*args, **kwargs)
    288 finally:
    289     set_eval_frame(prior)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py:440, in catch_errors_wrapper.<locals>.catch_errors(frame, cache_size, frame_state)
    437             return hijacked_callback(frame, cache_size, hooks, frame_state)
    439 with compile_lock:
--> 440     return callback(frame, cache_size, hooks, frame_state)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py:125, in wrap_convert_context.<locals>._fn(*args, **kwargs)
    123 cleanup = setup_compile_debug()
    124 try:
--> 125     return fn(*args, **kwargs)
    126 finally:
    127     cleanup.close()

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py:358, in convert_frame_assert.<locals>._convert_frame_assert(frame, cache_size, hooks, frame_state)
    343 initial_deterministic_algorithms_state = (
    344     torch.are_deterministic_algorithms_enabled()
    345 )
    347 signpost_event(
    348     "dynamo",
    349     "_convert_frame_assert._compile",
   (...)
    355     },
    356 )
--> 358 return _compile(
    359     frame.f_code,
    360     frame.f_globals,
    361     frame.f_locals,
    362     frame.f_builtins,
    363     compiler_fn,
    364     one_graph,
    365     export,
    366     export_constraints,
    367     hooks,
    368     frame,
    369     frame_state=frame_state,
    370 )

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/utils.py:180, in dynamo_timed.<locals>.dynamo_timed_inner.<locals>.time_wrapper(*args, **kwargs)
    178 with torch.profiler.record_function(f"{key} (dynamo_timed)"):
    179     t0 = time.time()
--> 180     r = func(*args, **kwargs)
    181     time_spent = time.time() - t0
    182 # print(f"Dynamo timer: key={key}, latency={latency:.2f} sec")

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py:428, in _compile(code, globals, locals, builtins, compiler_fn, one_graph, export, export_constraints, hooks, frame, frame_state)
    426 for attempt in itertools.count():
    427     try:
--> 428         out_code = transform_code_object(code, transform)
    429         orig_code_map[out_code] = code
    430         break

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/bytecode_transformation.py:1000, in transform_code_object(code, transformations, safe)
    997 instructions = cleaned_instructions(code, safe)
    998 propagate_line_nums(instructions)
-> 1000 transformations(instructions, code_options)
   1001 return clean_and_assemble_instructions(instructions, keys, code_options)[1]

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py:413, in _compile.<locals>.transform(instructions, code_options)
    398 tracer = InstructionTranslator(
    399     instructions,
    400     code,
   (...)
    410     frame_state=frame_state,
    411 )
    412 with tracing(tracer.output.tracing_context):
--> 413     tracer.run()
    414 output = tracer.output
    415 assert output is not None

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py:2019, in InstructionTranslator.run(self)
   2018 def run(self):
-> 2019     super().run()

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py:703, in InstructionTranslatorBase.run(self)
    698 try:
    699     self.output.push_tx(self)
    700     while (
    701         self.instruction_pointer is not None
    702         and not self.output.should_exit
--> 703         and self.step()
    704     ):
    705         pass
    706 except BackendCompilerFailed:

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py:663, in InstructionTranslatorBase.step(self)
    659         unimplemented(f"missing: {inst.opname}")
    660     TracingContext.set_current_loc(
    661         self.f_code.co_filename, self.lineno, self.f_code.co_name
    662     )
--> 663     getattr(self, inst.opname)(inst)
    665     return inst.opname != "RETURN_VALUE"
    666 except BackendCompilerFailed:

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py:2107, in InstructionTranslator.RETURN_VALUE(self, inst)
   2102 _step_logger()(
   2103     logging.INFO,
   2104     f"torchdynamo done tracing {self.f_code.co_name} (RETURN_VALUE)",
   2105 )
   2106 log.debug("RETURN_VALUE triggered compile")
-> 2107 self.output.compile_subgraph(
   2108     self,
   2109     reason=GraphCompileReason(
   2110         "return_value", [self.frame_summary()], graph_break=False
   2111     ),
   2112 )
   2113 self.output.add_output_instructions([create_instruction("RETURN_VALUE")])

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/output_graph.py:727, in OutputGraph.compile_subgraph(self, tx, partial_convert, reason)
    724     append_prefix_insts()
    725     # optimization to generate better code in a common case
    726     self.add_output_instructions(
--> 727         self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)
    728         + [create_instruction("UNPACK_SEQUENCE", arg=len(stack_values))]
    729     )
    730     codegen = PyCodegen(tx)
    731 else:

File ~/.pyenv/versions/3.9.13/lib/python3.9/contextlib.py:79, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
     76 @wraps(func)
     77 def inner(*args, **kwds):
     78     with self._recreate_cm():
---> 79         return func(*args, **kwds)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/output_graph.py:829, in OutputGraph.compile_and_call_fx_graph(self, tx, rv, root)
    826 name = unique_id("__compiled_fn")
    828 assert_no_fake_params_or_buffers(gm)
--> 829 compiled_fn = self.call_user_compiler(gm)
    830 compiled_fn = disable(compiled_fn)
    832 counters["stats"]["unique_graphs"] += 1

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/utils.py:180, in dynamo_timed.<locals>.dynamo_timed_inner.<locals>.time_wrapper(*args, **kwargs)
    178 with torch.profiler.record_function(f"{key} (dynamo_timed)"):
    179     t0 = time.time()
--> 180     r = func(*args, **kwargs)
    181     time_spent = time.time() - t0
    182 # print(f"Dynamo timer: key={key}, latency={latency:.2f} sec")

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/output_graph.py:888, in OutputGraph.call_user_compiler(self, gm)
    886     assert callable(compiled_fn), "compiler_fn did not return callable"
    887 except Exception as e:
--> 888     raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
    889         e.__traceback__
    890     ) from None
    891 return compiled_fn

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/output_graph.py:884, in OutputGraph.call_user_compiler(self, gm)
    881 if config.verify_correctness:
    882     compiler_fn = WrapperBackend(compiler_fn)
--> 884 compiled_fn = compiler_fn(gm, self.example_inputs())
    885 _step_logger()(logging.INFO, f"done compiler function {name}")
    886 assert callable(compiled_fn), "compiler_fn did not return callable"

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/repro/after_dynamo.py:117, in wrap_backend_debug.<locals>.debug_wrapper(gm, example_inputs, **kwargs)
    115             raise
    116 else:
--> 117     compiled_gm = compiler_fn(gm, example_inputs)
    119 return compiled_gm

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/repro/after_dynamo.py:117, in wrap_backend_debug.<locals>.debug_wrapper(gm, example_inputs, **kwargs)
    115             raise
    116 else:
--> 117     compiled_gm = compiler_fn(gm, example_inputs)
    119 return compiled_gm

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/__init__.py:1538, in _TorchCompileInductorWrapper.__call__(self, model_, inputs_)
   1535 def __call__(self, model_, inputs_):
   1536     from torch._inductor.compile_fx import compile_fx
-> 1538     return compile_fx(model_, inputs_, config_patches=self.config)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_inductor/compile_fx.py:610, in compile_fx(model_, example_inputs_, inner_compile, config_patches, decompositions)
    608 if config_patches:
    609     with config.patch(config_patches):
--> 610         return compile_fx(
    611             model_,
    612             example_inputs_,
    613             # need extra layer of patching as backwards is compiled out of scope
    614             inner_compile=config.patch(config_patches)(inner_compile),
    615             decompositions=decompositions,
    616         )
    618 if config.cpp_wrapper:
    619     with config.patch({"cpp_wrapper": False}):

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_inductor/compile_fx.py:720, in compile_fx(model_, example_inputs_, inner_compile, config_patches, decompositions)
    716     decompositions = select_decomp_table()
    717 # TODO: can add logging before/after the call to create_aot_dispatcher_function
    718 # in torch._functorch/aot_autograd.py::aot_module_simplified::aot_function_simplified::new_func
    719 # once torchdynamo is merged into pytorch
--> 720 return aot_autograd(
    721     fw_compiler=fw_compiler,
    722     bw_compiler=bw_compiler,
    723     inference_compiler=inference_compiler,
    724     decompositions=decompositions,
    725     partition_fn=partition_fn,
    726     keep_inference_input_mutations=True,
    727 )(model_, example_inputs_)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/backends/common.py:55, in aot_autograd.<locals>.compiler_fn(gm, example_inputs)
     52 try:
     53     # NB: NOT cloned!
     54     with enable_aot_logging(), patch_config:
---> 55         cg = aot_module_simplified(gm, example_inputs, **kwargs)
     56         counters["aot_autograd"]["ok"] += 1
     57         return eval_frame.disable(cg)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py:3686, in aot_module_simplified(mod, args, fw_compiler, bw_compiler, partition_fn, decompositions, keep_inference_input_mutations, inference_compiler)
   3669         break
   3671 aot_config = AOTConfig(
   3672     fw_compiler=fw_compiler,
   3673     bw_compiler=bw_compiler,
   (...)
   3683     no_tangents=False,
   3684 )
-> 3686 compiled_fn = create_aot_dispatcher_function(
   3687     functional_call,
   3688     full_args,
   3689     aot_config,
   3690 )
   3692 # TODO: There is something deeply wrong here; compiled_fn running with
   3693 # the boxed calling convention, but aot_module_simplified somehow
   3694 # historically returned a function that was not the boxed calling
   3695 # convention.  This should get fixed...
   3696 def forward(*runtime_args):

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_dynamo/utils.py:180, in dynamo_timed.<locals>.dynamo_timed_inner.<locals>.time_wrapper(*args, **kwargs)
    178 with torch.profiler.record_function(f"{key} (dynamo_timed)"):
    179     t0 = time.time()
--> 180     r = func(*args, **kwargs)
    181     time_spent = time.time() - t0
    182 # print(f"Dynamo timer: key={key}, latency={latency:.2f} sec")

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py:3225, in create_aot_dispatcher_function(flat_fn, flat_args, aot_config)
   3222 compiler_fn = partial(aot_wrapper_dedupe, compiler_fn=compiler_fn)
   3223 # You can put more passes here
-> 3225 compiled_fn = compiler_fn(flat_fn, fake_flat_args, aot_config, fw_metadata=fw_metadata)
   3226 if aot_config.is_export:
   3227     # During export, we don't get back a callable - we get back the raw fx graph
   3228     # (either a joint or an inference-only graph)
   3229     assert isinstance(compiled_fn, torch.fx.GraphModule)

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py:2090, in aot_wrapper_dedupe(flat_fn, flat_args, aot_config, compiler_fn, fw_metadata)
   2087         break
   2089 if ok:
-> 2090     return compiler_fn(flat_fn, leaf_flat_args, aot_config, fw_metadata=fw_metadata)
   2092 # export path: ban duplicate inputs for now, add later if requested.
   2093 if aot_config.is_export:

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py:2270, in aot_wrapper_synthetic_base(flat_fn, flat_args, aot_config, fw_metadata, needs_autograd, compiler_fn)
   2268 # Happy path: we don't need synthetic bases
   2269 if synthetic_base_info is None:
-> 2270     return compiler_fn(flat_fn, flat_args, aot_config, fw_metadata=fw_metadata)
   2272 # export path: ban synthetic bases for now, add later if requested.
   2273 if aot_config.is_export:

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py:2698, in aot_dispatch_autograd(flat_fn, flat_args, aot_config, fw_metadata)
   2691 with track_graph_compiling(aot_config, "joint"):
   2692     num_inner_fwd_outputs = (
   2693         fw_metadata.num_mutated_inputs
   2694         + fw_metadata.num_outputs
   2695         + fw_metadata.num_intermediate_bases
   2696         + fw_metadata.num_outputs_rng_offset
   2697     )
-> 2698     fw_module, bw_module = aot_config.partition_fn(
   2699         fx_g, joint_inputs, num_fwd_outputs=num_inner_fwd_outputs
   2700     )
   2701     fw_outs = [n for n in fw_module.graph.nodes if n.op == "output"][0].args[0]
   2702     # we only need to bookkeep the symints that are saved for bw, not any symints
   2703     # the user forward might have returned in its own output

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_inductor/compile_fx.py:691, in compile_fx.<locals>.partition_fn(graph, joint_inputs, **kwargs)
    689 def partition_fn(graph, joint_inputs, **kwargs):
    690     joint_graph_passes(graph)
--> 691     return min_cut_rematerialization_partition(
    692         graph, joint_inputs, **kwargs, compiler="inductor"
    693     )

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/torch/_functorch/partitioners.py:572, in min_cut_rematerialization_partition(joint_module, _joint_inputs, compiler, recomputable_ops, num_fwd_outputs)
    569         nx_graph.add_edge(node.name + "_out", user.name + "_in", capacity=math.inf)
    571 try:
--> 572     cut_value, partition = nx.minimum_cut(nx_graph, "source", "sink")
    573 except Exception:
    574     print('Failed to compute min-cut on following graph:')

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/networkx/algorithms/flow/maxflow.py:450, in minimum_cut(flowG, _s, _t, capacity, flow_func, **kwargs)
    447 if kwargs.get("cutoff") is not None and flow_func is preflow_push:
    448     raise nx.NetworkXError("cutoff should not be specified.")
--> 450 R = flow_func(flowG, _s, _t, capacity=capacity, value_only=True, **kwargs)
    451 # Remove saturated edges from the residual network
    452 cutset = [(u, v, d) for u, v, d in R.edges(data=True) if d["flow"] == d["capacity"]]

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/networkx/algorithms/flow/preflowpush.py:421, in preflow_push(G, s, t, capacity, residual, global_relabel_freq, value_only)
    291 def preflow_push(
    292     G, s, t, capacity="capacity", residual=None, global_relabel_freq=1, value_only=False
    293 ):
    294     r"""Find a maximum single-commodity flow using the highest-label
    295     preflow-push algorithm.
    296 
   (...)
    419 
    420     """
--> 421     R = preflow_push_impl(G, s, t, capacity, residual, global_relabel_freq, value_only)
    422     R.graph["algorithm"] = "preflow_push"
    423     return R

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/networkx/algorithms/flow/preflowpush.py:41, in preflow_push_impl(G, s, t, capacity, residual, global_relabel_freq, value_only)
     38 else:
     39     R = residual
---> 41 detect_unboundedness(R, s, t)
     43 R_nodes = R.nodes
     44 R_pred = R.pred

File ~/.pyenv/versions/3.9.13/envs/speech-synthesis/lib/python3.9/site-packages/networkx/algorithms/flow/utils.py:166, in detect_unboundedness(R, s, t)
    164 if attr["capacity"] == inf and v not in seen:
    165     if v == t:
--> 166         raise nx.NetworkXUnbounded(
    167             "Infinite capacity path, flow unbounded above."
    168         )
    169     seen.add(v)
    170     q.append(v)

BackendCompilerFailed: backend='inductor' raised:
NetworkXUnbounded: Infinite capacity path, flow unbounded above.


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


### Minified repro
```
from math import inf
import torch
from torch import tensor, device
import torch.fx as fx
import torch._dynamo
from torch._dynamo.testing import rand_strided
from torch._dynamo.debug_utils import run_fwd_maybe_bwd

import torch._dynamo.config
import torch._inductor.config
import torch._functorch.config
torch._dynamo.config.dynamic_shapes = True







from torch.nn import *
class Repro(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.fn = TransformerEncoderLayer(
  (self_attn): MultiheadAttention(
    (out_proj): NonDynamicallyQuantizableLinear(in_features=256, out_features=256, bias=True)
  )
  (linear1): Linear(in_features=256, out_features=1024, bias=True)
  (dropout): Dropout(p=0.1, inplace=False)
  (linear2): Linear(in_features=1024, out_features=256, bias=True)
  (norm1): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
  (norm2): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
  (dropout1): Dropout(p=0.1, inplace=False)
  (dropout2): Dropout(p=0.1, inplace=False)
).cuda()



    def forward(self, s0 : torch.SymInt, L_args_0_ : torch.Tensor, L_kwargs_src_key_padding_mask_ : torch.Tensor):
        l_args_0_ = L_args_0_
        l_kwargs_src_key_padding_mask_ = L_kwargs_src_key_padding_mask_
        fn = self.fn(l_args_0_, src_key_padding_mask = l_kwargs_src_key_padding_mask_);  l_args_0_ = l_kwargs_src_key_padding_mask_ = None
        return (fn,)


mod = Repro()

def load_args(reader):
    reader.symint(4)  # s0
    buf0 = reader.storage('9f95f7c87f974d44cb26549585199e0822f2f95a', 40960, device=device(type='cuda', index=0))
    reader.tensor(buf0, (10, 4, 256))  # L_args_0_
    buf1 = reader.storage('b80de5d138758541c5f05265ad144ab9fa86d1db', 40, device=device(type='cuda', index=0), dtype_hint=torch.bool)
    reader.tensor(buf1, (10, 4), dtype=torch.bool)  # L_kwargs_src_key_padding_mask_
load_args._version = 0

if __name__ == '__main__':
    from torch._dynamo.repro.after_dynamo import run_repro
    run_repro(mod, load_args, accuracy=False, command='minify',
        save_dir='/home/model/torch_compile_debug/run_2023_05_22_23_33_18_460611-pid_308743/minifier/checkpoints', autocast=False, backend=None)
```
### Versions

Collecting environment information...
PyTorch version: 2.1.0.dev20230519+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Clang version: Could not collect
CMake version: version 3.26.0
Libc version: glibc-2.35

Python version: 3.9.13 (main, Sep  6 2022, 01:37:16)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.19.0-41-generic-x86_64-with-glibc2.35
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 4090
Nvidia driver version: 530.30.02
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
Address sizes:                   46 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          32
On-line CPU(s) list:             0-31
Vendor ID:                       GenuineIntel
Model name:                      13th Gen Intel(R) Core(TM) i9-13900K
CPU family:                      6
Model:                           183
Thread(s) per core:              2
Core(s) per socket:              24
Socket(s):                       1
Stepping:                        1
CPU max MHz:                     5900,0000
CPU min MHz:                     800,0000
BogoMIPS:                        5990.40
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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                  VT-x
L1d cache:                       896 KiB (24 instances)
L1i cache:                       1,3 MiB (24 instances)
L2 cache:                        32 MiB (12 instances)
L3 cache:                        36 MiB (1 instance)
NUMA node(s):                    1
NUMA node0 CPU(s):               0-31
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] pytorch-triton==2.1.0+7d1a95b046
[pip3] torch==2.1.0.dev20230519+cu121
[pip3] torch-position-embedding==0.8.0
[pip3] torchaudio==2.1.0.dev20230520+cu121
[pip3] triton==2.0.0
[conda] Could not collect


cc @ezyang @msaroufim @wconstab @ngimel @bdhirsh @anijain2305