feat: Update vendored llama.cpp to include ModernBERT support

Aperta
#2,144 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
c, cmake, python

Direzione di ricerca

L’issue richiede di aggiornare il sottomodulo vendored llama.cpp a un commit successivo al 22 dicembre 2025 e quindi di aggiornare i binding Python ctypes in llama_cpp/llama_cpp.py in modo che corrispondano alla C API modificata (ad esempio, llama_get_kv_self non esiste più). È inoltre necessario correggere CMakeLists.txt, soprattutto per quanto riguarda LLAVA_BUILD. Inizia esaminando il sottomodulo corrente vendor/llama.cpp e il codice dei binding, quindi controlla le modifiche alla C API di llama.cpp nel commit di destinazione. La compilazione con -DLLAVA_BUILD=OFF è un workaround, ma i binding devono essere completamente compatibili. Il lavoro è completato quando la libreria riesce a caricare modelli ModernBERT GGUF senza errori.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Python
Stelle
10.7k
Fork
1.5k
Merge medio
1h 40m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di abetlen/llama-cpp-python

Tutte le issue di abetlen/llama-cpp-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.