fix(embeddings): make CUDA batch size configurable for small GPUs#368
Merged
Conversation
Fixes #344. LEANN_CUDA_BATCH_SIZE / LEANN_MPS_BATCH_SIZE / LEANN_CPU_THREADS env vars and --embedding-batch-size CLI override hardcoded defaults; cap CUDA batch by free VRAM after model load and halve on OOM retry. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Tested this on the exact small-GPU setup from #344 and it works — it turns the OOM into a clean build. 👍 Setup: NVIDIA RTX A1000 Laptop GPU (4 GB), WSL2, Results
Two small notes from the run, in case they're useful:
Neither blocks anything — this is a complete fix for #344: env/CLI override and VRAM autoscale + OOM retry, with no new dependency. Once it merges I'll drop our local monkey-patch in favor of these knobs. Thanks @ASuresh0524! |
Collaborator
Author
|
Awesome, thanks @ArtifexSystems. That helps a lot! Will incorporate these two small changes. |
Address PR #368 review: use a more conservative seq^2-based VRAM estimate so small GPUs land near batch 76 without relying on OOM retry, and only auto-cap when batch size comes from adaptive defaults (not --embedding-batch-size). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Fixes #344. LEANN_CUDA_BATCH_SIZE / LEANN_MPS_BATCH_SIZE / LEANN_CPU_THREADS env vars and --embedding-batch-size CLI override hardcoded defaults; cap CUDA batch by free VRAM after model load and halve on OOM retry.
Checklist
uv run pytest)ruff formatandruff check)pre-commit run --all-files)