Skip to content

ggml-metal : fix unary kernels compile on older Metal toolchains - #31360

Merged
ggerganov merged 1 commit into
masterfrom
gg/metal-unary-bf16-constexpr
Oct 29, 2026
Merged

ggerganov merged 1 commit into
masterfrom
gg/metal-unary-bf16-constexpr

Conversation

@ggerganov

Copy link
Copy Markdown
Member

Overview

Remove constexpr from the ggml_metal_unary_cast bfloat specializations, which fail to compile with -Winvalid-constexpr on the Metal toolchains of macOS 14 / 15, breaking Metal backend init (see #31272).

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES
    • Harness: dsh:llama.cpp
    • Hardware: MacBook, M5 Max, 128GB
    • Model: ggml-org/Qwen3.8-Flash-Next-GGUF
    • Stats: ◷ 20.5m · ⚙ 3.6m · ↑ 76k · ↓ 56k · ⇈ 600.0 tok/s · ⇊ 51.3 tok/s · ≡ 212 · ⌨ 16

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (MacBook, M5 Max, 128GB)
@ggerganov
ggerganov marked this pull request as ready for review October 29, 2026 08:09
@ggerganov
ggerganov requested a review from a team as a code owner October 29, 2026 08:09
@ggerganov
ggerganov merged commit c9daee1 into master Oct 29, 2026
14 checks passed
@ggerganov
ggerganov deleted the gg/metal-unary-bf16-constexpr branch October 29, 2026 08:09
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Apple Metal https://en.wikipedia.org/wiki/Metal_(API) labels Oct 29, 2026
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 30, 2026
…l-org#31360)

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (MacBook, M5 Max, 128GB)
xkong-anaconda added a commit to AnacondaRecipes/llama.cpp-feedstock that referenced this pull request Nov 2, 2026
llama.cpp 0.8.0

**Destination channel:** defaults

### Links
- [PKG-19394](https://anaconda.atlassian.net/browse/PKG-19394)
- [Upstream
release](https://github.com/ggml-org/llama.cpp/releases/tag/v0.8.0)
- [Upstream
diff](ggml-org/llama.cpp@v0.7.0...v0.8.0)
- [win-arm64 CUDA 13.4 off-CI build: logs and
artifacts](https://drive.google.com/drive/folders/1z-GI6wHJ0VIly_vBpAGGm5sSmFPODNh0?usp=sharing)

### Explanation of changes:
- Updated llama.cpp from 0.7.0 (b11669) to **0.8.0** (b11960). 
- **win-arm64 CUDA CI failure is expected:** win-arm64 CUDA 13.4 CI
compiles, then fails creating its test environment with `nothing
provides __cuda needed by libllama-0.8.0-cuda134_had9b3fb_100`. The
win-arm64 CI workers have no GPU, so the `__cuda` virtual package needed
by the CUDA tests is missing, and the libllama / llama.cpp /
llama.cpp-tests CUDA test tasks fail for the same reason. This is an
infrastructure limitation, not a recipe problem; the win-arm64 CPU
variant builds and tests green in the same graph. As for previous
releases, the CUDA variant was built and tested off-CI on a win-arm64
machine with an NVIDIA GPU (linked above): all 3 outputs build and pass
their tests, ctest 35/35, `test-backend-ops -b CUDA0` 19192/19192, plus
model inference, llama-server (including the web UI) and router mode.
- ctest now selects tests labelled `main` or `behavior` and excludes
`model` and `python`, matching whole words . Upstream relabelled most
unit tests from `main` to `behavior`, so `-L main` alone would select
only 8. The new selection keeps every previously run test and adds the
two speculative-decoding tests: 42 → 44 on CPU, 39 → 40 on Metal, and 31
→ 35 on Windows (which also gains test-generate-models and
test-llama-context). On Metal, test-speculative-rejection-sampling is
excluded: it hits the same `GGML_ASSERT(buf_dst)` on the CI Mac (macOS
13) as test-thread-safety and test-llama-context, and passes 3/3 with
this PR's Metal package on an M4 Pro / macOS 15.7.3 once the shader fix
below is applied.
- Backported upstream
[#31360](ggml-org/llama.cpp#31360)
(`fix-metal-unary-bf16-constexpr.patch`). Without it the Metal package
fails every context creation on macOS 14 and 15: the `constexpr bfloat4`
casts new in 0.8.0 don't compile (upstream
[#31272](ggml-org/llama.cpp#31272),
[#31337](ggml-org/llama.cpp#31337)).
Reproduced with this PR's CI Metal package on an M4 Pro / macOS 15.7.3.
CI can't see it: the CI Mac runs macOS 13, where BF16 is off and this
code never compiles.
- llama-server's web UI is now built from source (`npm ci` on upstream's
lockfile, then `vite build`; `nodejs` added to build) instead of
downloading upstream's prebuilt bundle from a Hugging Face bucket
(`LLAMA_USE_PREBUILT_UI`, default ON; 0.7.0 shipped the download too).
The build fails if no UI was built, since upstream otherwise falls back
silently to a UI-less server. `llama-ui-licenses.md` (Vite's license
manifest, enabled by `ui-license-manifest.patch`) lists the licenses of
the 179 bundled npm packages.
- `test-backend-load` now requires a CUDA device on CUDA variants, so a
broken CUDA backend can't pass on the CPU backend alone.
- Smaller fixes: the Metal device fallback in
`metal_gpu_selection.patch` no longer leaks the device array or releases
devices it doesn't own (the file builds without ARC); `fix-models-path`
and `disable-metal-flash-attention` are refreshed to apply without
offsets; llama.cpp-tools also skips py>=3.15 (upstream `requires-python
<3.15`); `openblas-devel` uses the `openblas_devel` CBC key.
- New llama.cpp-tools test: fail if any `conversion`/`examples` import
in the installed package was not redirected by
`fix-convert_hf_to_gguf.patch`, including function-local ones such as
`--dspark`.
- gguf and llama.cpp-tools stay off win-arm64, with a corrected reason:
the only win-arm64 transformers (5.20.2) constrains `mistral-common
>=1.11.7`, which isn't on any channel yet (PKG-19294). gguf has no
blocker of its own; it is skipped there only because it builds in the
same output set.



[PKG-19394]:
https://anaconda.atlassian.net/browse/PKG-19394?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
xkong-anaconda added a commit to AnacondaRecipes/llama.cpp-feedstock that referenced this pull request Nov 5, 2026
llama.cpp 0.9.0

**Destination channel:** defaults

### Links
- [PKG-19636](https://anaconda.atlassian.net/browse/PKG-19636)
- [Upstream
release](https://github.com/ggml-org/llama.cpp/releases/tag/v0.9.0)
- [Upstream
diff](ggml-org/llama.cpp@v0.8.0...v0.9.0)

### Explanation of changes:
- Updated llama.cpp from 0.8.0 (b11960) to **0.9.0** (b12110). 
- **win-arm64 CUDA CI failure is expected**: the GPU-less win-arm64
workers can't create the CUDA test environment. The CUDA 13.4 variant
will be built and tested off-CI on a win-arm64 machine with an NVIDIA
GPU, as for previous releases.
- Dropped two patches that upstream now includes:
`fix-metal-unary-bf16-constexpr.patch` (upstream
[#31360](ggml-org/llama.cpp#31360)) and
`link-test-backend-ops-threads.patch` (upstream
[#31414](ggml-org/llama.cpp#31414) links
`Threads::Threads` itself).
- **gguf and llama.cpp-tools are built on win-arm64**
- Release builds now set `-DLLAMA_BUILD_IS_DEV=OFF`. Upstream defaults
to a dev build, so 0.8.0 shipped `llama.pc` and the CMake package
versioned `0.8.0-dev` and `find_package(llama 0.8.0 EXACT)` failed. A
new libllama test checks that the installed `llama.pc` reports exactly
`{{ version }}`.


[PKG-19636]:
https://anaconda.atlassian.net/browse/PKG-19636?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
yhirose added a commit to yhirose/culebra that referenced this pull request Nov 6, 2026
llama.cpp v0.8.0's unary.metal declares its bfloat casts constexpr, which the
Metal compiler of macOS 14 and 15 rejects at run time, so on an Apple Silicon
Mac running either, every Llama.load with the GPU failed with
"failed to build 'unary' library" (ggml-org/llama.cpp#31360). The macOS CI
runners are macOS 26, whose compiler accepts it.

cpp-llamalib v0.9.0 pins its llama.cpp in one set(LLAMA_CPP_VERSION ...)
line and reads it with scripts/llama-cpp-version.sh; check_llama_versions.sh
now asks that script instead of reading GIT_TAG itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Apple Metal https://en.wikipedia.org/wiki/Metal_(API) ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant