M1 Mac, MPS: Buffer is not large enough
Labels: triaged, module: mps

### 🐛 Describe the bug

Issue related to #87351: `Error: buffer is not large enough. Must be 600 bytes`
Not sure if it is the same issue though as my use case is somewhat different. But I can confirm all reproductions suggested in comments of #87351 crash for me as well.

In my case, trying to repurpose the code from [this repository](https://github.com/naver/sqlova) to work using MPS.
After running
`python3 train.py --seed 1 --bS 16 --accumulate_gradients 2 --bert_type_abb uS --fine_tune --lr 0.001 --lr_bert 0.00001 --max_seq_leng 222 --tepoch 10 --do_train`

Output:
```
BERT-type: uncased_L-12_H-768_A-12
Batch_size = 32
BERT parameters:
learning rate: 1e-05
Fine-tune BERT: True
vocab size: 30522
hidden_size: 768
num_hidden_layer: 12
num_attention_heads: 12
hidden_act: gelu
intermediate_size: 3072
hidden_dropout_prob: 0.1
attention_probs_dropout_prob: 0.1
max_position_embeddings: 512
type_vocab_size: 2
initializer_range: 0.02
Load pre-trained parameters.
Seq-to-SQL: the number of final BERT layers to be used: 2
Seq-to-SQL: the size of hidden dimension = 100
Seq-to-SQL: LSTM encoding layer size = 2
Seq-to-SQL: dropout rate = 0.3
Seq-to-SQL: learning rate = 0.001
/AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Types/MPSNDArray.mm:782: failed assertion `[MPSNDArray, initWithBuffer:descriptor:] Error: buffer is not large enough. Must be 600 bytes'
python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 20 leaked semaphore objects to clean up at shutdown
```
I currently suspect the issue is somehow related to the `torch.utils.data.DataLoader` function, as I do **not** get the error when setting `batch_size` to 1. The error does show up when using any `batch_size` greater than 1. Notably, the number of bytes required in the error message also changes depending on `batch_size`, eg:
```
[...] --bS 8 --accumulate_gradients 2 [...]
Batch_size = 16
...
Error: buffer is not large enough. Must be 396 bytes
```
```
[...] --bS 4 --accumulate_gradients 2 [...]
Batch_size = 8
...
Error: buffer is not large enough. Must be 280 bytes
```
Also worth noting that changing the value of the `--accumulate_gradients` argument does not impact whether the code runs successfully: `--bS 4 --accumulate_gradients 8 \\ Batch_size = 32` will crash, while `--bS 1 --accumulate_gradients 32 \\ Batch_size = 32` will run. Given that `--accumulate_gradients` is not passed to `torch.utils.data.DataLoader`, I suspect it rather has to do with `batch_size`, though I could also be completely off the mark, this is just what I have observed while running the code.

Happy to provide any further details if it helps identify the issue!
cc @kulinseth @albanD @malfet @DenisVieriu97 @razarmehr @abhudev @ebraminio

### Versions


Python version:
```
python --version 
Python 3.9.13
```

Torch versions:
```
pip freeze | grep torch
pytorch-pretrained-bert==0.6.2
torch==1.14.0.dev20221027
torchaudio==0.14.0.dev20221025
torchvision==0.15.0.dev20221027
```