Repository navigation
fix: avoid empty embedding decode batches - #2442
Open
remote-controlled-man wants to merge 2 commits into
Open
remote-controlled-man wants to merge 2 commits into
remote-controlled-man wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Empty input lists currently reach llama_decode with no tokens and raise RuntimeError. Texts that tokenize to no tokens can also create empty sequences, so an empty string either fails decoding or produces inconsistent results depending on its position in a batch.
Skip decoding when no sequences were accumulated, and reject tokenless texts with a clear ValueError before adding them to the native batch. Empty lists return no embeddings with zero token usage. Empty strings that tokenize to special tokens remain supported.
Real-model regressions cover embed and create_embedding, pooled and unpooled empty lists, zero-token strings on their own and in either position of a mixed batch, legal empty strings with special tokens, and reuse after empty calls or errors.
Validation:
Local environment: macOS arm64, Python 3.12.14, native llama.cpp f5e6915c2 built with GGML_NATIVE=OFF (CPU/Accelerate and Metal available). New regressions use CPU model layers and the existing cached Qwen3.5-0.8B and BGE-small fixtures. Other platforms and acceleration backends were not run locally.
AI assistance: Codex helped diagnose, implement, test and independently review this change.