feat(embedder): add configurable batch_size#274
Open
ibreakshit wants to merge 1 commit into
Open
Conversation
Add an optional embedder.batch_size config option that caps the number of inputs per embedding API request (default 2000, unchanged). Slow or self-hosted embedding endpoints can time out on a single large request and fail the whole initial scan; lowering batch_size keeps each request short so indexing completes as more, smaller requests. - config: EmbedderConfig.BatchSize (yaml: batch_size) - embedder: additive FormBatchesWithSize; FormBatches delegates with the MaxBatchSize default (no behavior change); out-of-range values fall back to default - indexer: per-Indexer batchSize (default MaxBatchSize) + SetBatchSize; batched embed path uses FormBatchesWithSize - cli/watch: apply cfg.Embedder.BatchSize - tests + docs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Summary
Adds an optional
embedder.batch_sizeconfig option that caps the number of inputs per embedding API request. Default is2000(unchanged).Motivation
On slow or self-hosted OpenAI-compatible embedding endpoints, grepai's initial scan packs the entire batch (up to
MaxBatchSize= 2000) into a single/v1/embeddingsrequest. When the endpoint is slow, that one request exceeds the embedder's client timeout and the whole initial index fails:There is currently no config-level way to work around this. Lowering
batch_sizekeeps each request short so indexing completes reliably as more, smaller requests (slower overall, but it finishes). On throughput-bound endpoints it pairs well withparallelism: 1.Changes
EmbedderConfig.BatchSize(yaml: batch_size)FormBatchesWithSize(files, maxBatchSize);FormBatchesnow delegates to it with theMaxBatchSizedefault (no behavior change). Values<= 0or> MaxBatchSizefall back to the default.IndexerbatchSize(defaults toMaxBatchSize) +SetBatchSize; the batched embed path usesFormBatchesWithSize.cfg.Embedder.BatchSizeto the indexer for both the single-project and workspace paths.FormBatchesWithSizecustom size, default fallback,FormBatchesdelegation) and docs.Backward compatibility
Fully backward compatible. Unset /
<= 0/> MaxBatchSizeall use the existing 2000 default;FormBatchesbehaves exactly as before. TheMaxBatchTokenslimit still applies.Testing
🤖 Generated with Claude Code