Skip to content

added language model embed component - #714

Merged
HenryNdubuaku merged 2 commits into
mainfrom
karen/embed_fix
Jun 11, 2026
Merged

HenryNdubuaku merged 2 commits into
mainfrom
karen/embed_fix

Conversation

@kar-m

@kar-m kar-m commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 05:55
@kar-m

kar-m commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator Author

@jakmro added embedding capability for langauge models, tested on lfm, qwen, gemma4. Haven't tested gemma3
validated against hf
Essentially jsut added an extra component that runs like chunked prefill but doesnt include lmhead (some extra transpiler stuff for gemma)

Copilot AI 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.

Pull request overview

This PR adds a new decoder_embed_chunk component across the transpile pipeline and runtime, enabling “embedding readout” from causal-LM hidden states (in addition to existing text_embedding encoder-style bundles). It also updates the server to expose embeddings for any bundle that contains the relevant embedding-capable component.

Changes:

  • Add decoder_embed_chunk component specs/adapters for Gemma4, Qwen3, and LFM2-VL to return last_hidden_state (no lm_head).
  • Extend lowering/bundling/planning logic to recognize and emit decoder_embed_chunk.
  • Update runtime/server embedding routing to support both text_embedding and LM-hidden-state embeddings, and add engine-side pooling/normalization for LM embeddings.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/cactus/transpile/model_adapters.py Adds embed-chunk adapters/specs for multiple model families (returns hidden states instead of logits).
python/cactus/transpile/lower.py Allows internal KV/conv cache lowering for the new decoder_embed_chunk component.
python/cactus/transpile/hf_model.py Ensures decoder_embed_chunk is included in component bundle ordering/manifest writing.
python/cactus/transpile/component_plan.py Includes decoder_embed_chunk in the auto plan for chunked Qwen3 causal-LM pipelines.
python/cactus/server.py Switches embedding capability detection from hardcoded model types to manifest-based component presence.
cactus-engine/src/model.cpp Adds LM-embedding execution path and shared L2-normalization helper.
cactus-engine/src/engine.h Exposes new embedding APIs (get_text_embeddings, get_lm_embeddings) and capability checks.
cactus-engine/src/embed.cpp Routes FFI embedding calls through get_text_embeddings (supports both embedding modes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

},
metadata={"family": family, "task": "causal_lm_logits"},
))
if "decoder_prefill_chunk" in requested_set:
Comment on lines +3308 to +3312
reset_component_cache_states(*decoder_embed_);
decoder_embed_->graph->release_runtime_buffers();
decoder_embed_->graph->release_all_weight_pages();
unload_component_graph(*decoder_embed_);
return finalize_pooled_embedding(sum, count, normalize);
@HenryNdubuaku
HenryNdubuaku merged commit 1db5aad into main Jun 11, 2026
4 of 6 checks passed
ncylich added a commit that referenced this pull request Jun 11, 2026
Union resolutions: rope-table externalization (#713) runs before the
general materialized-constant externalizer; decoder_embed_chunk (#714)
emitted via the unified LFM2 chunked-spec helper and added to the qwen3
text component plan; gemma3 and needle convert families coexist.

Signed-off-by: Noah Cylich <noahcylich@gmail.com>
ncylich added a commit that referenced this pull request Jun 11, 2026
Union resolutions: rope-table externalization (#713) runs before the
general materialized-constant externalizer; decoder_embed_chunk (#714)
emitted via the unified LFM2 chunked-spec helper and added to the qwen3
text component plan; gemma3 and needle convert families coexist.

Signed-off-by: Noah Cylich <noahcylich@gmail.com>
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.

3 participants