Repository navigation
fix: Bound embedding input length and attention memory per batch - #837
Draft
buildingjoshbetter wants to merge 2 commits into
Draft
buildingjoshbetter wants to merge 2 commits into
buildingjoshbetter 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.
Embedding models were run with their full input limit (32,768 tokens for Qwen3-Embedding-0.6B) and a fixed 32-text batch. Attention memory grows with batch × length², so one batch of long texts could need tens of GB. On a Mac it fails on MPS first and is then retried on CPU. This applies the same dynamic bound as the reranker change (#836) to every embedding path and tier.
encodecall, with no measurement, for single texts, tensor or list outputs, and batches that fit even at the smallest budget.Real Qwen3-Embedding-0.6B on CPU, 32 synthetic texts per call, 16 GiB container, peak cgroup memory before → after:
Single-query latency: 30.77 ms → 30.87 ms median over 200 calls (within noise).
Validation at aa37923, stacked on #836:
tests/test-model-daemon-admission-297.pypins the exact bytes ofmps_utils.pyto guard against unintended edits. The pin is updated to the reviewed bytes; themps_utils.pychange is the three guardedbudgeted_encodecall sites.Base is
maintenance/reranker-token-budget-v1(#836). Draft; no merges or releases.