performance drop because batching rule for aten::_scaled_dot_product_attention_math is not yet implemented
Labels: module: vmap, oncall: transformer/mha, module: functorch

### 🐛 Describe the bug

Pretty much doing what the stacktrace is asking. I am trying to write a batched implementation of the DETR code in the original paper (https://arxiv.org/pdf/2005.12872.pdf), where a single set of queries is decoded over a batch containing several images, without using a custom transformer implementation. torch.vmap seemed like the ideal function for the job. As far as I can tell, my implementation works, but I get the following stacktrace: 
```bash
/anaconda3/envs/detr_env/lib/python3.11/site-packages/torch/nn/functional.py:5373: UserWarning: There is a performance drop because we have not yet implemented the batching rule for aten::_scaled_dot_product_attention_math. Please file us an issue on GitHub so that we can prioritize its implementation. (Triggered internally at /opt/conda/conda-bld/pytorch_1682343904035/work/aten/src/ATen/functorch/BatchedFallback.cpp:82.)
  attn_output = scaled_dot_product_attention(q, k, v, attn_mask, dropout_p, is_causal)
```

This "bug" can be reproduced with the following code: 

```python
from torch.nn import Transformer 
from torch import vmap, rand

transformer = Transformer()
vmap_transformer = vmap(transformer, in_dims=(1, None), randomness="same")
src, tgt = rand((32, 8, 512)), rand((32, 512))
out = vmap_transformer(src, tgt)
```
I am on PyTorch CPU, I've seen other people getting similar errors on GPUs but I apologize if this fact makes this bug report irrelevant. 

### Versions

Collecting environment information...
PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Fedora Linux 38 (Workstation Edition) (x86_64)
GCC version: (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1)
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.37

Python version: 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.5.5-200.fc38.x86_64-x86_64-with-glibc2.37
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:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             8
On-line CPU(s) list:                0-7
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
CPU family:                         6
Model:                              142
Thread(s) per core:                 2
Core(s) per socket:                 4
Socket(s):                          1
Stepping:                           10
CPU(s) scaling MHz:                 89%
CPU max MHz:                        3400.0000
CPU min MHz:                        400.0000
BogoMIPS:                           3600.00
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 pni pclmulqdq dtes64 monitor ds_cpl vmx 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 pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust sgx bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          128 KiB (4 instances)
L1i cache:                          128 KiB (4 instances)
L2 cache:                           1 MiB (4 instances)
L3 cache:                           6 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-7
Vulnerability Gather data sampling: Mitigation; Microcode
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 Retbleed:             Mitigation; IBRS
Vulnerability Spec rstack overflow: 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; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Mitigation; Microcode
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] efficientnet-pytorch==0.7.1
[pip3] numpy==1.26.0
[pip3] segmentation-models-pytorch==0.3.3
[pip3] torch==2.0.1
[pip3] torchaudio==2.0.2
[pip3] torchvision==0.15.2
[conda] blas                      1.0                         mkl  
[conda] cpuonly                   2.0                           0    pytorch
[conda] efficientnet-pytorch      0.7.1                    pypi_0    pypi
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46343  
[conda] mkl-service               2.4.0           py311h5eee18b_1  
[conda] mkl_fft                   1.3.8           py311h5eee18b_0  
[conda] mkl_random                1.2.4           py311hdb19cb5_0  
[conda] numpy                     1.26.0          py311h08b1b3b_0  
[conda] numpy-base                1.26.0          py311hf175353_0  
[conda] pytorch                   2.0.1              py3.11_cpu_0    pytorch
[conda] pytorch-mutex             1.0                         cpu    pytorch
[conda] segmentation-models-pytorch 0.3.3                    pypi_0    pypi
[conda] torchaudio                2.0.2                 py311_cpu    pytorch
[conda] torchvision               0.15.2                py311_cpu    pytorch


cc @zou3519 @jbschlosser @bhosmer @cpuhrsch @erichan1 @drisspg @Chillee @samdow @kshitij12345 @janeyx99