Skip to content

EmbeddingGemma-2 support - #247

Closed
danielhanchen wants to merge 2 commits into
base/upstream-b9a5a00b8from
embeddinggemma-2
Closed

danielhanchen wants to merge 2 commits into
base/upstream-b9a5a00b8from
embeddinggemma-2

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

EmbeddingGemma 2 support (google/embeddinggemma-2), by @ngxson, for the nightly pin set.

Two commits by @ngxson, cherry-picked unchanged onto b11436 (the current nightly base):

  • model: add embeddinggemma2: the gemma-embedding2 architecture, its graph and the converter.
  • add mtmd support: images and audio through the existing Gemma 4 vision and audio projectors.

Together they are +324 / -2 across 10 files, the same lines as the upstream change. This replaces #246, which put source into fork master.

Testing

Local mirror of unsloth-pin-preflight.yml on b11436:

  • All 14 current pins merge in order, then this commit (additive resolve).
  • merge_checks.py is clean and pin_contract.py reports all pins intact.
  • llama-embedding on the BF16 GGUF built from the merged tree matches a build of the upstream change.

@danielhanchen
danielhanchen requested a review from CISC as a code owner October 6, 2026 16:00
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T16:16:37.238232Z 73c2f73 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73c2f733e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread conversion/gemma.py
class EmbeddingGemma2VisionAudioModel(Gemma4VisionAudioModel):
def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
# same towers as Gemma4, but the tensor names have no "model." prefix
yield from super().modify_tensors(data_torch, "model." + name, bid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Filter prefixless text tensors from mmproj conversion

When --mmproj processes an EmbeddingGemma2 checkpoint, the inherited MmprojModel.filter_tensors() rejects only language_model.*, but this architecture's language weights are prefixless (layers.*, ple.*, and embedding_projection.*). They therefore reach this method, receive an invalid model. prefix, and are passed through the vision mapping path, where map_tensor_name() raises ValueError: Can not map tensor ...; consequently the newly added image/audio projector cannot be converted from the normal full checkpoint. Add a model-specific filter that retains only the vision and audio tower tensors before applying the prefix.

Useful? React with 👍 / 👎.

ggml_tensor * llama_model_gemma_embedding2::graph::build_inp_per_layer(ggml_tensor * inpL) {
const int64_t n_embd_per_layer = hparams.n_embd_per_layer;

ggml_tensor * cur = ggml_mul_mat(ctx0, model.per_layer_model_proj, inpL); // [n_embd_per_layer * n_layer, n_tokens]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply LoRA adapters to the PLE model projection

When a LoRA includes weights for per_layer_model_proj, this raw ggml_mul_mat bypasses the adapter lookup performed by build_lora_mm, even though the other linear projections in this new graph use that helper. The adapter can therefore load without an error while this projection continues using only the base weight, producing incorrect per-layer inputs and embeddings; route this multiplication through build_lora_mm as well.

AGENTS.md reference: AGENTS.md:L83-L83

Useful? React with 👍 / 👎.

Shreesh-Sree pushed a commit to Shreesh-Sree/llama.cpp that referenced this pull request Oct 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Upstream ggml-org#30054 landed EmbeddingGemma-2 support, and tags from b11452 on carry all of it, so this pin is no longer needed.

EmeraldBitTwizzler pushed a commit to EmeraldBitTwizzler/llama.cpp that referenced this pull request Oct 9, 2026
…at merge past b11453, drop unslothai#247, pin unslothai#251

Upstream K2 Horizon (ggml-org#29535), the glm5-next gather removal (ggml-org#30042) and the
GLM5-Next MTP graph (ggml-org#29928) broke the Inkling, unslothai#243 and unslothai#241 pins. Each
branch now carries a merge of upstream master. unslothai#247 is in every tag from
b11452 on. unslothai#251 adds --moe-cache-mib auto on top of ggml-org#29887.
EmeraldBitTwizzler pushed a commit to EmeraldBitTwizzler/llama.cpp that referenced this pull request Oct 9, 2026
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