You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Llama.embed() calls LlamaBatch.add_sequence with old 3-arg signature; missing logits_array #2211
llama_cpp/llama_embedding.py (around line 262) already calls add_sequence correctly with the four-arg shape — the call site in Llama.embed() was apparently missed during the LlamaBatch.add_sequence refactor.
$ python --version
Python 3.12.9
$ pip show llama-cpp-python | findstr Version
Version: 0.3.36
Failure Information (for bugs)
This is a clean regression — LlamaBatch.add_sequence was refactored from a 3-arg signature to a 4-arg one, and the call sites were updated everywhere except in Llama.embed(). llama_embedding.py shows what the new shape should look like for the embedding code path.
Monkey-patching LlamaBatch.add_sequence to detect 3-arg legacy calls and synthesize the missing pos_array works as a stopgap. Hit while running Tencent's HY-Motion text-to-motion model, whose text encoder uses Llama.embed() against GGUF Qwen3 weights.
After investigating the current codebase (0.3.23), it appears this was fixed as part of the recent embedding fixes in #2205. LlamaBatch.add_sequence now uses a 3-arg signature. Could a maintainer confirm and close this if resolved?
I'd like to work on fixing this bug. The issue is clear: Llama.embed() is calling LlamaBatch.add_sequence() with the old 3-argument signature, but the method now requires 4 arguments after the refactor.
I've analyzed the code and found:
The problematic call is in llama_cpp/llama.py around line 1678
The correct 4-argument call pattern is already implemented in llama_cpp/llama_embedding.py around line 262
The fix is straightforward: update the call to match the new signature
I'll prepare a PR with:
Fix the add_sequence() call in Llama.embed()
Add a regression test to ensure this doesn't break again
Is this still needed? I want to make sure I'm not duplicating any existing work.
Activity
SanjanaB123 commentedon May 13, 2026
After investigating the current codebase (0.3.23), it appears this was fixed as part of the recent embedding fixes in #2205. LlamaBatch.add_sequence now uses a 3-arg signature. Could a maintainer confirm and close this if resolved?
lxcxjxhx commentedon Jul 7, 2026
Hi @abetlen and maintainers,
I'd like to work on fixing this bug. The issue is clear:
Llama.embed()is callingLlamaBatch.add_sequence()with the old 3-argument signature, but the method now requires 4 arguments after the refactor.I've analyzed the code and found:
llama_cpp/llama.pyaround line 1678llama_cpp/llama_embedding.pyaround line 262I'll prepare a PR with:
add_sequence()call inLlama.embed()Is this still needed? I want to make sure I'm not duplicating any existing work.
Thanks!