Batching rule not implemented for `aten::t`
Labels: triaged, oncall: pt2, module: functorch, module: dynamo

### 🐛 Describe the bug

When using `torch.t()` inside `torch.vmap`, `torch.compile` fails with `Batching rule not implemented for aten::t`. A minimal example (using the `traceable` function from https://github.com/pytorch/pytorch/issues/98822):

```python
import torch
from torch import nn
from torch._dynamo import allow_in_graph
from functools import wraps

def traceable(f):
    f = allow_in_graph(f)

    @wraps(f)
    def wrapper(*args, **kwargs):
        return f(*args, **kwargs)

    return wrapper

x = torch.randn(3, 5, 3)

func = lambda x: x.t()
# This works
torch.vmap(func)(x)

# This does not work
torch.compile(traceable(torch.vmap(func)))(x)
```

Full error log

```
Traceback (most recent call last):
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 1194, in run_node
    return node.target(*args, **kwargs)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_functorch/vmap.py", line 434, in wrapped
    return _flat_vmap(
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_functorch/vmap.py", line 39, in fn
    return f(*args, **kwargs)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_functorch/vmap.py", line 619, in _flat_vmap
    batched_outputs = func(*batched_inputs, **kwargs)
  File "/Users/lin/Desktop/Hi/hay.py", line 17, in <lambda>
    func = lambda x: x.t()
RuntimeError: Batching rule not implemented for aten::t; the fallback path doesn't work on out= or view ops.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 1152, in get_fake_value
    return wrap_fake_exception(
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 808, in wrap_fake_exception
    return fn()
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 1153, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 1206, in run_node
    raise RuntimeError(
RuntimeError: Failed running call_function <function <lambda> at 0x7fcc1af794c0>(*(FakeTensor(FakeTensor(..., device='meta', size=(3, 5, 3)), cpu),), **{}):
Batching rule not implemented for aten::t; the fallback path doesn't work on out= or view ops.
(scroll up for backtrace)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/lin/Desktop/Hi/hay.py", line 22, in <module>
    torch.compile(traceable(torch.vmap(func)))(x)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 337, in catch_errors
    return callback(frame, cache_size, hooks)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 1002, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars.items)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/variables/torch.py", line 548, in call_function
    tensor_variable = wrap_fx_proxy(
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/variables/builder.py", line 754, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/variables/builder.py", line 789, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/Users/lin/anaconda3/envs/drqv2/lib/python3.9/site-packages/torch/_dynamo/utils.py", line 1173, in get_fake_value
    raise TorchRuntimeError() from e
torch._dynamo.exc.TorchRuntimeError:

from user code:
   File "/Users/lin/Desktop/Hi/hay.py", line 11, in wrapper
    return f(*args, **kwargs)

Set torch._dynamo.config.verbose=True for more information


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True
```

This is particularly relevant when implementing parallel ensembles since `torch.nn.functional.linear` calls `torch.Tensor.t()`, as in the following example:

```python
import torch
from torch import nn
from torch._dynamo import allow_in_graph
from functools import wraps
from torch.func import stack_module_state, functional_call
import functorch
import copy

def traceable(f):
    f = allow_in_graph(f)

    @wraps(f)
    def wrapper(*args, **kwargs):
        return f(*args, **kwargs)

    return wrapper

x = torch.randn(3)

class Net(torch.nn.Module):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.fc = nn.Linear(3, 5)

    def forward(self, x):
        return self.fc(x)


# Following the same recipe as https://pytorch.org/tutorials/intermediate/ensembling.html
models = [Net() for _ in range(5)]
params, buffers = stack_module_state(models)

# Construct a "stateless" version of one of the models. It is "stateless" in
# the sense that the parameters are meta Tensors and do not have storage.
base_model = copy.deepcopy(models[0])
base_model = base_model.to('meta')

def fmodel(params, buffers, x):
    return functional_call(base_model, (params, buffers), (x,))
vmapped_fmodel = functorch.vmap(fmodel, in_dims=(0, 0, None))

# Works
vmapped_fmodel(params, buffers, x)

# Doesn't work
torch.compile(traceable(vmapped_fmodel))(params, buffers, x)
```

By the way, `torch.compile` a vmapped ensemble is what I ultimately wanted to do. Is there any simple trick to get around the above issue?


### Versions

PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.5.1 (x86_64)
GCC version: (Homebrew GCC 7.5.0_4) 7.5.0
Clang version: 13.0.0 (clang-1300.0.29.30)
CMake version: version 3.21.3
Libc version: N/A

Python version: 3.9.17 (main, Jul  5 2023, 16:17:03)  [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-10.16-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz

Versions of relevant libraries:
[pip3] numpy==1.25.2
[pip3] torch==2.0.1
[pip3] torchvision==0.15.2
[conda] numpy                     1.25.2                   pypi_0    pypi
[conda] torch                     2.0.1                    pypi_0    pypi
[conda] torchvision               0.15.2                   pypi_0    pypi


cc @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @zou3519 @Chillee @samdow @kshitij12345 @janeyx99 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng