The code below exits with this error: /AppleInternal/Library/BuildRoots/.../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 1024 bytes
import torch
mps = torch.device("mps")
size = 16
A = torch.rand(size, device=mps)
F = torch.rand(size, size, size, device=mps)
print(A@F)
That’s a bug that the PyTorch team needs to fix. Metal throws a fatal error if the descriptor doesn’t match the allocated buffer’s size. @albanD does the backend compile with Metal API validation on? I can’t remember whether that would trigger such an assertion failure, or if MPS’s validation mechanisms are strictly independent of the underlying Metal framework.
Hi,
Thanks for the report. That does look like a bug on our end!
Could you open an issue on github with this code sample so that we can easily track the fix for this?
I have the error.
/AppleInternal/Library/BuildRoots/8d3bda53-8d9c-11ec-abd7-fa6a1964e34e/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 32768 bytes
’
I use Macbook Pro M1 (Monterey), PyCharm, homebrew, miniforge3. It starts after the last line of code in script. Everything else runs as it should.
Last line of code:
train(bert_classifier, train_dataloader, val_dataloader, epochs=2, evaluation=True)