Skip to content

Update llama.cpp to v0.7.0 (adds EmbeddingGemma 2 support) - #1175

Open
willsheldon wants to merge 3 commits into
utilityai:mainfrom
willsheldon:llama-cpp-bump-gemma-embedding2
Open

willsheldon wants to merge 3 commits into
utilityai:mainfrom
willsheldon:llama-cpp-bump-gemma-embedding2

Conversation

@willsheldon

Copy link
Copy Markdown

Moves the llama-cpp-sys-2/llama.cpp submodule from v0.6.0 (d812350) to v0.7.0 (620d222).

The range includes ggml-org/llama.cpp#30054 (4fbc76d), which adds the gemma-embedding2 architecture. Without it, loading embeddinggemma-2-Q8_0.gguf fails with unknown model architecture: 'gemma-embedding2'. 4fbc76d is an ancestor of v0.7.0.

API change ported

llama_perf_context_data gains n_reallocs_same and n_reallocs_diff. LlamaTimings::new builds the struct literal, so it now initialises both fields to 0. Its public signature does not change. The C++ wrappers compile unchanged.

Behaviour change to note

ggml-org/llama.cpp#30445 and #30255 stop computing logits for pooled embedding contexts (embeddings enabled and a pooling type other than None, set explicitly or taken from the GGUF metadata). On such a context, after decode, LlamaContext::get_logits and get_logits_ith now panic, and LlamaSampler::sample aborts on GGML_ASSERT(logits != nullptr). With v0.6.0 these calls returned logits. The in-repo embeddings and reranker examples read only embeddings and are not affected. This PR does not change the wrappers for this; it may be worth a note in the with_embeddings docs.

Testing

macOS arm64, Rust 1.98.0, with the commands from llama-cpp-rs-check.yml:

  • cargo fmt --check: pass
  • cargo clippy: pass (warnings only, none from this change)
  • cargo build --features sampler,mtmd,llguidance: pass
  • cargo test --features sampler,mtmd,llguidance: pass (23 unit, 4 integration, 94 doc tests; 3 doc tests ignored)
  • cargo publish --workspace --dry-run: pass

Functional check with ggml-org/embeddinggemma-2-GGUF embeddinggemma-2-Q8_0.gguf (sha256 2188ac1deca4b77dffefd603c2776a9d76d9d74ec01841392982ebb840b09135), using cargo run --release -p embeddings -- local <model>:

  • At v0.7.0 the model loads (arch = gemma-embedding2) and the example returns a 768-dim embedding (n_embd_out = 768, n_embd = 512).
  • At v0.6.0 the same command fails with unknown model architecture: 'gemma-embedding2'.

Linux, Windows, CUDA and Emscripten builds were not run locally; CI covers them. The dynamic-link feature was not built locally and is not in CI. ggml-org/llama.cpp#30014 hides non-GGML_API symbols in shared ggml builds; every ggml function the crate calls is GGML_API, so no break is expected.

🤖 Generated with Claude Code

The submodule moves from v0.6.0 to v0.7.0. This range includes
ggml-org/llama.cpp#30054, which adds the gemma-embedding2 architecture.
Before this update, loading embeddinggemma-2-Q8_0.gguf fails with
"unknown model architecture: 'gemma-embedding2'".

The only breaking change that needed a port is in llama_perf_context_data.
It gains two fields, n_reallocs_same and n_reallocs_diff. LlamaTimings::new
keeps its signature and initialises both new fields to 0.

Tested on macOS arm64 with the CI commands (clippy, fmt, build, test). The
embeddings example loads embeddinggemma-2-Q8_0.gguf and returns 768-dim
embeddings.
@willsheldon

Copy link
Copy Markdown
Author

Branch updated with current main (cc 1.8.0). This bumps llama.cpp to v0.7.0, which adds EmbeddingGemma 2 support. All CI targets passed on the previous head. Could a maintainer review when convenient? We are pinned to this rev downstream until a release includes it.

@madsmtm madsmtm left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expose the new fields in LlamaTimings::new, we don't worry too much about breaking API changes (yet).

Addresses review feedback on utilityai#1175. LlamaTimings::new now takes the two
fields that llama.cpp v0.7.0 added to llama_perf_context_data, instead of
setting them to 0.
@willsheldon

Copy link
Copy Markdown
Author

Done in 424d1ff: LlamaTimings::new now takes n_reallocs_same and n_reallocs_diff. Thanks for the review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants