The RX 580 Metal port
Two patches that put Stable Diffusion 2.1 on an AMD RX 580. Apply them on top of a clean upstream checkout.
Patch it in one go
Get the bundle from the repo, then run the helper from inside your checkout:
git clone https://github.com/thiensubs/wave64-report
git clone https://github.com/leejet/stable-diffusion.cpp
cd stable-diffusion.cpp
git checkout 5356982
git submodule update --init --recursive
bash ../wave64-report/sd-cpp/apply.sh .
No downloads, no installs: the helper runs git apply on the two patch files next to it. Read it first — that is the point. Manual steps are below if you prefer them.
Direct link, if you want it without cloning: apply.sh
https://app8601830087.tgcloud.ai/r/rx580-white-images-fix/sd-cpp/apply.sh
| Provenance | |
|---|---|
| upstream | leejet/stable-diffusion.cpp @ 5356982584d5b46a8f5cb0842927aff6443fe174 |
ggml submodule | d49c49e1dd361ba3c0a77c90b5b1404b83969aa8 |
| generated | 2026-11-04, from the fork's working tree — the work was uncommitted |
| apply point | both patches pass git apply --check at exactly those two commits (verified 2026-11-04) |
Files
- 0001-ggml-metal-rx580.patch — 24 files: Metal device, ops and impl, the width-64 kernels, the
fa_vec_*guards, the tiled SIMT GEMM inmul_mv.metal, padded threadgroup memory - 0002-group-norm-inplace.patch —
src/core/ggml_extend.cpp, one file:group_normuses the out-of-place ops - ALGORITHM.md — what changes and why, in four ideas
- README.md — the same instructions as this page, as Markdown
Apply
git clone https://github.com/leejet/stable-diffusion.cpp
cd stable-diffusion.cpp
git checkout 5356982
git submodule update --init --recursive
git apply /path/to/0002-group-norm-inplace.patch
cd ggml
git apply /path/to/0001-ggml-metal-rx580.patch
cd ..
0001 applies inside ggml/ because its paths are relative to that submodule.
Build (Mac with Metal)
cmake -B build -DGGML_METAL=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --target sd-cli test-backend-ops -j8
Stale kernels. The build copies kernels/*.metal into build/bin/kernels/. Edit a kernel without rebuilding and you are running the old one — a silent no-op on this port.
Status
Uncommitted work in the author's fork; the numbers in the report were measured with it. No benchmark claim is made on this page.
Upstream thread: leejet/stable-diffusion.cpp#2271 — asking whether the port is in scope and how to split the PR.