perf: raise ONNX default batch size to 64#608
Draft
j-sperling wants to merge 1 commit into
Draft
Conversation
Measured on the default int8 bge-m3 model (CPU, Apple M-series, 128 texts): 13.2s at batch 32, 11.7s at 64, 10.6s at 128. 64 gives ~11% indexing throughput over the old default; 128 is left to explicit configuration because worst-case padded batches of 8192-token inputs materialize multi-GB activation tensors.
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
OnnxEmbedding._DEFAULT_BATCH_SIZEfrom 32 to 64. Measured on the defaultgpahal/bge-m3-onnx-int8(CPU, Apple M-series, 128 texts x ~230 tokens): 14.1s @ batch 16, 13.2s @ 32, 11.7s @ 64, 10.6s @ 128 — so 64 is ~11% faster than the current default. On corpus-scale indexing (observed >4.5h for 186K chunks with this model) that's tens of minutes.max_length=8192, so a worst-case batch of long texts at 128-wide materializes multi-GB activation tensors. 64 keeps the worst case bounded while capturing most of the win; users can still setembedding.batch_size = 128in config where memory allows.embedding.batch_sizeconfig continues to override;0still means "provider default".Test plan
ruff check/ruff format --checkcleantime.perf_counteraroundembed()