Closed
Description
What happened?
I encountered a crash in ggml_metal_init
when the first bfloat kernel is added. Below is an explanation of what I believe is happening. My device is running macOS 15.0.1 and has an M3 Max.
Because the macOS platform version in Package.swift
is .v12
, the condition to disable bfloat, __METAL_VERSION__ < 310
, will always be true. However, at runtime the device family is used to set has_bfloat
. As a result, there can be a bfloat mismatch between the Swift package's compiled Metal library and the runtime flag. This leads to a crash when adding bfloat Metal kernels as they don't exist.
Some ideas:
- Consider bumping the macOS platform version to
.v14
so consumers of the Swift package can use bfloat. - Set
has_bfloat
by also checking for the existence of an empty kernel in theMTLLibrary
that will only exist if the library was compiled with bfloat support.
Name and Version
version: 4043 (60e17ce)
built with Apple clang version 16.0.0 (clang-1600.0.26.4) for arm64-apple-darwin24.0.0
What operating system are you seeing the problem on?
Mac
Relevant log output
No response