Repository: pytorch
Issue: torch._inductor.exc.LoweringException in `torch._export.aot_compile` 
Labels: oncall: pt2,oncall: export,module: aotinductor

### 🐛 Describe the bug

Install most recent diffusers, torchao and pytorch
```
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121
pip install git+https://github.com/huggingface/diffusers
pip install torchao
```

<details>
<summary>Repro</summary>

```python
import torch
from diffusers import FluxPipeline, FluxTransformer2DModel
import torch.utils.benchmark as benchmark
from functools import partial
from torchao.quantization import quantize_, int8_weight_only

def get_example_inputs():
    example_inputs = {
        "hidden_states": torch.randn(1, 4096, 64, dtype=torch.bfloat16, device="cuda"),
        "encoder_hidden_states": torch.randn(1, 512, 4096, dtype=torch.bfloat16, device="cuda"),
        "pooled_projections": torch.randn(1, 768, dtype=torch.bfloat16, device="cuda"),
        "timestep": torch.tensor([1.0], device="cuda"),
        "img_ids": torch.randn(4096, 3, dtype=torch.bfloat16, device="cuda"),
        "txt_ids": torch.randn(512, 3, dtype=torch.bfloat16, device="cuda"),
        "guidance": None,
        "joint_attention_kwargs": None,
        "return_dict": False
    }
    return example_inputs

def benchmark_fn(f, *args, **kwargs):
    t0 = benchmark.Timer(
        stmt="f(*args, **kwargs)",
        globals={"args": args, "kwargs": kwargs, "f": f},
        num_threads=torch.get_num_threads(),
    )
    return f"{(t0.blocked_autorange().mean):.3f}"

def load_model():
    model = FluxTransformer2DModel.from_pretrained(
        "black-forest-labs/FLUX.1-schnell", subfolder="transformer", torch_dtype=torch.bfloat16
    ).to("cuda")
    return model

def aot_compile(name, model, **sample_kwargs):
    path = f"./{name}.so"
    print(f"{path=}")
    options = {
        "aot_inductor.output_path": path,
        "max_autotune": True,
        "triton.cudagraphs": True,
    }

    torch._inductor.aoti_compile_and_package(
        torch.export.export(model, (), sample_kwargs),
        (),
        sample_kwargs,
    )
    # torch._export.aot_compile(
    #     fn,
    #     (),
    #     sample_kwargs,
    #     options=options,
    #     disable_constraint_solver=True,
    # )
    return path

def aot_load(path):
    return torch._export.aot_load(path, "cuda")

@torch.no_grad()
def f(model, **kwargs):
    return model(**kwargs)

model = load_model()
quantize_(model, int8_weight_only())
inputs1 = get_example_inputs()
from torchao.utils import unwrap_tensor_subclass
unwrap_tensor_subclass(model)
path1 = aot_compile("bs_1_1024", model, **inputs1)

compiled_func_1 = aot_load(path1)
print(f"{compiled_func_1(**inputs1)[0].shape=}")

for _ in range(5):
    _ = compiled_func_1(**inputs1)[0]

time = benchmark_fn(f, compiled_func_1, **inputs1)
print(time)

```
</details>

<details>
<summary>Error</summary>

```

Fetching 3 files:   0%|          | 0/3 [00:00<?, ?it/s]
Fetching 3 files: 100%|██████████| 3/3 [00:00<00:00, 40072.97it/s]
Traceback (most recent call last):
  File "/data/users/jerryzh/transformers/repro.py", line 70, in <module>
    path1 = aot_compile("bs_1_1024", model, **inputs1)
  File "/data/users/jerryzh/transformers/repro.py", line 44, in aot_compile
    torch._inductor.aoti_compile_and_package(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/__init__.py", line 91, in aoti_compile_and_package
    aoti_files = aot_compile(m, args, kwargs, options=inductor_configs)  # type: ignore[arg-type]
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/__init__.py", line 204, in aot_compile
    return compile_fx_aot(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1153, in compile_fx_aot
    compiled_lib_path = compile_fx(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1330, in compile_fx
    return compile_fx(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1369, in compile_fx
    return compile_fx(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1593, in compile_fx
    return inference_compiler(unlifted_gm, example_inputs_)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1424, in fw_compiler_base
    return _fw_compiler_base(model, example_inputs, is_inference)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 1495, in _fw_compiler_base
    return inner_compile(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 470, in compile_fx_inner
    return wrap_compiler_debug(_compile_fx_inner, compiler_name="inductor")(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_dynamo/repro/after_aot.py", line 85, in debug_wrapper
    inner_compiled_fn = compiler_fn(gm, example_inputs)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 664, in _compile_fx_inner
    compiled_graph = codegen_and_compile(
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 565, in codegen_and_compile
    compiled_graph = fx_codegen_and_compile(gm, example_inputs, **fx_kwargs)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/compile_fx.py", line 875, in fx_codegen_and_compile
    compiled_fn = graph.compile_to_fn()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/graph.py", line 1969, in compile_to_fn
    code, linemap = self.codegen_with_cpp_wrapper()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/graph.py", line 1840, in codegen_with_cpp_wrapper
    return self.codegen()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/graph.py", line 1854, in codegen
    self.scheduler.codegen()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/scheduler.py", line 3449, in codegen
    return self._codegen()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/scheduler.py", line 3514, in _codegen
    self.codegen_extern_call(node)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/scheduler.py", line 3396, in codegen_extern_call
    node.codegen(V.graph.wrapper_code)
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/ir.py", line 5152, in codegen
    kernel_name = self.get_kernel_name()
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/ir.py", line 4558, in get_kernel_name
    V.graph.wrapper_code.get_c_shim_func_name(self.cpp_kernel_name)  # type: ignore[attr-defined]
  File "/home/jerryzh/anaconda3/envs/diffuser/lib/python3.9/site-packages/torch/_inductor/codegen/cpp_wrapper_cpu.py", line 1164, in get_c_shim_func_name
    if kernel.startswith("aoti_torch_"):
AttributeError: 'NoneType' object has no attribute 'startswith'
```

</details>


### Versions

main

cc @ezyang @chauhang @penguinwu @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4 @desertfire @chenyang78