Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Eval bug: Metal BF16 shader fails to compile on macOS 15.5: invalid constexpr

Open Beginner friendly
#31,337 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, macos

Research direction

Start by locating the two bfloat4 conversion specializations for ggml_metal_unary_cast in the Metal shader sources and review how they use constexpr. The report says removing constexpr from both specializations lets the Metal library compile and the model generate output; verify this on macOS 15.5 with the listed model, then confirm the Metal build and inference succeed.

Written by the indexing model from the issue text.

Description

bug-unconfirmed
Name and Version

macOS 15.5 (24F74) and your Mac’s chip.
llama.cpp commit 522021325546ea322b0b1e58a50f9dbf03a5f197.
Model: LiquidAI LFM3-1.7B-BF16.gguf.
error: constexpr function never produces a constant expression
[-Winvalid-constexpr]

inline constexpr bfloat4
ggml_metal_unary_cast<bfloat4, float4>(float4 x)

ggml_metal_init: error: failed to initialize the Metal library

Workaround tested: Removed constexpr from the two bfloat4 conversion specializations, keeping inline and both function bodies unchanged. Rebuilt llama-server.
Result: The model loaded with Metal and successfully generated READY in a short inference test.

Operating systems

Mac

GGML backends

Metal

Hardware

Model | MacBook Pro (Mac14,9)
Chip | Apple M2 Pro
CPU | 10 cores: 6 performance + 4 efficiency
GPU | 16 cores, Metal supported
Memory | 16 GB unified memory
Architecture | ARM64 / Apple Silicon
macOS | 15.5 (24F74)

Models

LiquidAI/LFM3-1.7B-GGUF

Problem description & steps to reproduce

Failure: Loading the model failed while compiling the Metal shader:
error: constexpr function never produces a constant expression
[-Winvalid-constexpr]

inline constexpr bfloat4
ggml_metal_unary_cast<bfloat4, float4>(float4 x)

ggml_metal_init: error: failed to initialize the Metal library

First Bad Commit

No response

Relevant log output
Logs
constexpr function never produces a constant expression
[-Winvalid-constexpr]

inline constexpr bfloat4
ggml_metal_unary_cast<bfloat4, float4>(float4 x)

ggml_metal_init: error: failed to initialize the Metal library

Dominant language
C++
Stars
133k
Forks
24.9k
Avg merge
2d 52m
Merged PRs (30d)
496

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ggml-org/llama.cpp

All issues in ggml-org/llama.cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.