Repository navigation
Metal
Metal is the GPU path on macOS. It is part of both Mac builds: darwin-arm64 (Apple Silicon) and, since v1.0.50, darwin-x86_64 (Intel Macs). An Intel Mac uses it only with a discrete GPU that reports Metal 3; see Intel Macs. macOS has no Vulkan in this project. For Vulkan on the other platforms see GPU-Acceleration.
| Filter | On Metal | Notes |
|---|---|---|
whisper |
Yes | The backend name in the metadata is mtl. |
lyricsalign |
Allowed with use_gpu=1
|
Off by default. |
stemsplit, Spleeter |
No | The Spleeter graph runs on the CPU. See below. |
stemsplit, RoFormer |
Not enabled for auto
|
auto is the CPU on macOS. An explicit use_gpu=1 on Metal is not verified on hardware. |
stemsplit opens the Metal device and then asks it about every operation of the graph. ggml-metal in the pinned whisper.cpp refuses PAD with padding before the data. The Spleeter graph needs that padding. The filter logs a line that says the device cannot run PAD, and uses the CPU backend instead.
The result is correct. It is the CPU's output. No Metal speed-up comes from it.
The log is easy to misread. The first line, stemsplit: ggml backend 'mtl' (...), names the device that opened. It is printed before the graph check. Read the frame metadata for what ran:
ffmpeg -i in.mp3 -af "stemsplit=model=spleeter-2stems-f16.gguf:stem=vocals:use_gpu=1,ametadata=mode=print" -f null -lavfi.stemsplit.backend=cpu means the CPU computed it. mtl would mean Metal did.
A speed or bit-identity comparison of Spleeter with use_gpu=1 against use_gpu=0 on a Mac compares the CPU with the CPU. It says nothing about Metal.
ggml's registry calls the backend MTL. This project lower-cases whatever the registry reports. On an Apple Silicon Mac the log and the metadata read:
whisper: ggml backend 'mtl' (Apple M4 Pro).
A program that reads this value, for example a media server, must match mtl and not metal.
The Metal shader source is embedded in the executable. It is source text, not a compiled .metallib. The user's machine compiles it the first time it is needed.
| Item | Fact |
|---|---|
| Install | Nothing. Nothing extra ships. |
| First use | ggml builds the Metal device and compiles the embedded shader source when it first builds its backend registry. The project measured 6.262 s for that on an M4. Later calls in the same process do not pay it again. |
use_gpu=0 |
Does not start Metal. A CPU-only run does not pay the compile cost. |
| Frameworks |
Foundation, Metal, MetalKit
|
The build is made with osxcross. One ggml source line for macOS 15 residency sets is switched off for that toolchain. The build refuses to continue if that line is not found exactly once.
Every release candidate and release runs the Metal checks on an Apple Silicon machine; v1.0.50 passed them.
Metal on an Intel Mac is not verified on hardware. See the next section.
Since v1.0.50 the darwin-x86_64 build carries the same Metal backend as darwin-arm64. The filters follow the same rules as on Apple Silicon; see the table at the top. Whether Metal is used is decided at run time, from the Mac's default GPU.
| The Mac's default GPU | What runs |
|---|---|
| A discrete GPU that reports Metal 3: AMD Vega and the Radeon 5000 and 6000 series, on macOS 13 or later | Metal |
| A discrete GPU without Metal 3: Radeon Pro 4xx and 5xx, RX 580 | The CPU |
| Integrated graphics only | The CPU, as before v1.0.50 |
| Any GPU on a macOS that cannot report the GPU family (older than 10.15) | The CPU |
Why the rule is this strict:
- Without Metal 3, ggml refuses the matrix products on the GPU. The graph then moves between GPU and CPU for every one of them. That is slower than the CPU alone.
- Intel's integrated GPUs report Metal 3 too. Nobody has measured one with this backend, and they share memory and power with the CPU. They stay on the CPU until someone measures them.
Two environment variables change the choice:
| Variable | Effect |
|---|---|
NOMERCY_GGML_METAL=1 |
Takes the default GPU regardless of the rule above. It is meant for measuring the GPUs the rule leaves out. |
NOMERCY_GGML_GPU=0 |
Keeps every filter on the CPU. This works on every platform. |
Read lavfi.whisper.backend to see what ran: mtl or cpu.
Not run on an Intel Mac yet. The build is checked in CI: the backend is in the binary, and on a Mac without a discrete GPU the filters stay on the CPU. That the Metal result equals the CPU's, and that it is faster, is not measured. tools/metal/check-intel-mac.sh in the repository measures both on such a Mac.
Neither Mac build chooses a CPU level at run time. See CPU-Instruction-Sets.
VideoToolbox is built in on both Mac builds. See Codecs-and-Libraries.
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors