Repository: pytorch
Issue: [export] Failed to save the model using torch.export.save
Labels: triaged,oncall: pt2,module: dynamic shapes,export-triaged,oncall: export

### 🐛 Describe the bug

Facing this issue when we are saving the Torch-TensorRT compiled module using torch.export.save(). Here's a link to our exporter code. https://github.com/pytorch/TensorRT/blob/main/py/torch_tensorrt/dynamo/_exporter.py

```py
import torch

from torch.export import Dim
import torch.nn as nn
import torch_tensorrt as torchtrt
import os
import tempfile

class bitwise_and(nn.Module):
    def forward(self, lhs_val, rhs_val):
        return torch.ops.aten.bitwise_and.Tensor(lhs_val, rhs_val)

dyn_dim = Dim("dyn_dim", min=3, max=6)
lhs = torch.randint(0, 2, (2, 4, 2), dtype=bool, device="cuda")
rhs = torch.randint(0, 2, (4, 2), dtype=bool, device="cuda")
inputs = (lhs, rhs)
torchtrt_inputs = [torchtrt.Input(shape=lhs.shape, dtype=torch.bool), 
                   torchtrt.Input(shape=rhs.shape, dtype=torch.bool)] 
mod = bitwise_and()


fx_mod=torch.export.export(mod, inputs, dynamic_shapes={"lhs_val": {1: dyn_dim}, "rhs_val": {0: dyn_dim}})
print(f"lan added fx_mod={fx_mod}")
trt_model = torchtrt.dynamo.compile(fx_mod, inputs=inputs, enable_precisions={torch.bool}, min_block_size=1)
trt_ep_path = os.path.join(tempfile.gettempdir(), "trt.ep")

lhs1 = torch.randint(0, 2, (2, 5, 2), dtype=bool, device="cuda")
rhs1 = torch.randint(0, 2, (5, 2), dtype=bool, device="cuda")
torchtrt.save(trt_model, trt_ep_path, inputs=[lhs1, rhs1])
print(f"lan added saved model to {trt_ep_path}")

loaded_trt_module = torch.export.load(trt_ep_path)
print(f"lan added load model from {trt_ep_path}") 

output = loaded_trt_module(lhs1, rhs1)
print(f"lan added got {output=}")
```

Note: I'm not sure if this is a problem, but there's a warning that shows up 
```py
WARNING:py.warnings:/home/dperi/Downloads/TensorRT/py/torch_tensorrt/dynamo/_exporter.py:370: UserWarning: Attempted to insert a get_attr Node with no underlying reference in the owning GraphModule! Call GraphModule.add_submodule to add the necessary submodule, GraphModule.add_parameter to add the necessary Parameter, or nn.Module.register_buffer to add the necessary buffer
  engine_node = gm.graph.get_attr(engine_name)

WARNING:py.warnings:/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/graph.py:1586: UserWarning: Node _run_on_acc_0_engine target _run_on_acc_0_engine _run_on_acc_0_engine of  does not reference an nn.Module, nn.Parameter, or buffer, which is what 'get_attr' Nodes typically target
  warnings.warn(f'Node {node} target {node.target} {atom} of {seen_qualname} does '
```
The way we set TRT engines as a `getattr` is here: https://github.com/pytorch/TensorRT/blob/main/py/torch_tensorrt/dynamo/_exporter.py#L368-L370
Here's the full error message: 
```py
W0927 14:39:57.743000 2685898 site-packages/torch/fx/experimental/symbolic_shapes.py:5257] failed during evaluate_expr(s0 >= 0, hint=True, size_oblivious=False, forcing_spec=False
E0927 14:39:57.744000 2685898 site-packages/torch/fx/experimental/recording.py:298] failed while running evaluate_expr(*(s0 >= 0, True), **{'fx_node': False})
Traceback (most recent call last):
  File "/home/dperi/Downloads/TensorRT/test.py", line 32, in <module>
    loaded_trt_module = torch.export.load(trt_ep_path)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/export/__init__.py", line 569, in load
    ep = deserialize(artifact, expected_opset_version)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_export/serde/serialize.py", line 2445, in deserialize
    .deserialize(
     ^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_export/serde/serialize.py", line 2324, in deserialize
    .deserialize(
     ^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_export/serde/serialize.py", line 1908, in deserialize
    self.deserialize_graph(serialized_graph_module.graph)
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_export/serde/serialize.py", line 1614, in deserialize_graph
    meta_val = self.deserialize_tensor_meta(tensor_value)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_export/serde/serialize.py", line 1581, in deserialize_tensor_meta
    torch.empty_strided(
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1342, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2012, in _dispatch_impl
    op_impl_out = op_impl(self, func, *args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 176, in constructors
    r = func(*args, **new_kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/_ops.py", line 720, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 479, in expect_size
    r = b.expect_true(file, line)
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 465, in expect_true
    return self.guard_bool(file, line)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 449, in guard_bool
    r = self.shape_env.evaluate_expr(self.expr, self.hint, fx_node=self.fx_node)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 262, in wrapper
    return retlog(fn(*args, **kwargs))
                  ^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5255, in evaluate_expr
    return self._evaluate_expr(orig_expr, hint, fx_node, size_oblivious, forcing_spec=forcing_spec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5331, in _evaluate_expr
    static_expr = self._maybe_evaluate_static(expr,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1738, in wrapper
    return fn_cache(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 4686, in _maybe_evaluate_static
    r = _maybe_evaluate_static_worker(expr, symbol_info, unbacked_only, size_oblivious)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1554, in _maybe_evaluate_static_worker
    lower = vr.lower
            ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'
WARNING:py.warnings:/home/dperi/.pyenv/versions/3.11.7/lib/python3.11/tempfile.py:895: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/tmpg514wz8s'>
  _warnings.warn(warn_message, ResourceWarning)
```

cc: @angelayi 

### Versions

[pip3] torch==2.6.0.dev20240925+cu124
[pip3] torch_tensorrt==2.6.0.dev0+43eb56053
[pip3] torchmetrics==1.4.0.post0
[pip3] torchprofile==0.0.4
[pip3] torchsurgeon==0.1.2
[pip3] torchvision==0.20.0.dev20240927+cu124
[pip3] triton==3.0.0

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