MPSGraph fails with `MPSLibrary::MPSKey_Create internal error: Unable to get MPS kernel ndArrayConvolution2D.`

Hi, I'm writing a metal backend for the Leela Chess Zero NN-based chess engine, using MPSGraph for inference. I have found that I get an error: /System/Volumes/Data/SWE/macOS/BuildRoots/220e8a1b79/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.6.1/MPSCore/Utility/MPSLibrary.mm:311: failed assertion MPSLibrary::MPSKey_Create internal error: Unable to get MPS kernel ndArrayConvolution2D. whenever I run inference on the graph.

Does anyone know what would cause this error?

Answered by almaudoh in 712342022

I was only able to get past this issue after upgrading to macOS Monterey. So seems there is no solution for Big Sur.

Hi Could you please share the platform, OS and reproducible test case? Thanks

Reposting my response to above for more clarity

Platform: Mac mini (M1, 2020)

OS: Big Sur 11.6.2

Code is at https://github.com/almaudoh/lc0/tree/new-metal-backend-mpsgraph

You'd have to compile the executable from the source code. You need meson and ninja installed to compile.

Compile by running ./build.sh in the lc0 folder after cloning the repo above. You would also need to download a "weights" file that contains neural network weights. A sample can be downloaded here: https://storage.lczero.org/files/networks/b30e742bcfd905815e0e7dbd4e1bafb41ade748f85d006b8e28758f1a3107ae3

After compile, run /path/to/lc0/build/release/lc0 --weights=/path/to/weights/file --backend=metal where /path/to/weights/file refers to where you saved the downloaded neural network weights file.

Finally, in the lc0 command shell, run the command go infinite this starts to run the MPSGraph inference using the neural network stored in the weights file. This will throw the error mentioned above.

I realize this is a very involved process just to reproduce the error, but I hope it goes smoothly. Let me know if there are difficulties reproducing the error.

Thanks.

Accepted Answer

I was only able to get past this issue after upgrading to macOS Monterey. So seems there is no solution for Big Sur.

MPSGraph fails with `MPSLibrary::MPSKey_Create internal error: Unable to get MPS kernel ndArrayConvolution2D.`
 
 
Q