feat: Update vendored llama.cpp to include ModernBERT support

Open
#2,144 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
c, cmake, python

Research direction

The issue requires updating the vendored llama.cpp submodule to a commit after Dec 22, 2025, and then updating the Python ctypes bindings in llama_cpp/llama_cpp.py to match the changed C API (e.g., llama_get_kv_self is gone). Also, CMakeLists.txt needs fixes, especially around LLAVA_BUILD. Start by examining the current vendor/llama.cpp submodule and the binding code, then check the llama.cpp C API changes in the target commit. Building with -DLLAVA_BUILD=OFF is a workaround, but the bindings must be fully compatible. Done looks like the library can load ModernBERT GGUF models without errors.

Written by the indexing model from the issue text.

Description

Context

The current release (v0.3.16, Aug 15 2025) vendors llama.cpp at commit 4227c9b (Aug 14, 2025). ModernBERT architecture support was added to llama.cpp on Dec 22, 2025 in PR ggml-org/llama.cpp#15641 (src/models/modern-bert.cpp). The vendor submodule hasn't been updated in ~7 months.

Problem

Loading a ModernBERT GGUF model fails with:

llama_model_load: error loading model: error loading model architecture: unknown model architecture: 'modernbert'

The binary only knows: bert, falcon, gemma, gpt2, llama, mamba, qwen, rwkv, stablelm — no modernbert.

Attempted fix

We tried updating the vendor submodule to llama.cpp b8373 (Mar 16, 2026) and building from source. Results:

  1. CMake fails with LLAVA_BUILD=ON (default) — vendor/llama.cpp/tools/mtmd/CMakeLists.txt:37 has a set_target_properties error incompatible with the binding's CMakeLists.txt
  2. CMake succeeds with -DLLAVA_BUILD=OFF — builds and installs fine
  3. Runtime ABI mismatch — the Python bindings call llama_get_kv_self which no longer exists in b8373 (symbol not found). The C API has diverged significantly in 7 months.

So it's not just a submodule bump — the Python ctypes bindings need updates to match the current llama.cpp C API.

Why it matters

Several recent high-quality embedding models use ModernBERT architecture:

  • granite-embedding-small-english-r2 (IBM, 47M params, 384d, BEIR NDCG@10 50.9, Apache 2.0)
  • modernbert-embed-base (Nomic, 149M params, Apache 2.0)
  • gte-modernbert-base (Alibaba, 149M params)

These models can't be used with llama-cpp-python until the binding is updated.

Request

Update the Python ctypes bindings and CMakeLists.txt to be compatible with a recent llama.cpp build that includes ModernBERT support (post Dec 22, 2025).

Dominant language
Python
Stars
10.7k
Forks
1.5k
Avg merge
1h 40m
Merged PRs (30d)
5

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 abetlen/llama-cpp-python

All issues in abetlen/llama-cpp-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.