You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Gemini and OpenAI model handlers set no default max_batch_size; default embedding requests exceed the API's 2,048-input limit #41360
GeminiModelHandler and OpenAIModelHandler pass max_batch_size to BatchElements only if the user sets it, so with default settings batches grow without an upper bound.
Measured on master (de0e417) with default settings and fake clients (no network):
Pipeline
Result
OpenAIModelHandler with embedding_from_string, 60,000 inputs
requests of up to 10,000 inputs; 7 of 20 requests were over the 2,048 inputs the embeddings endpoint accepts
GeminiModelHandler with generate_from_string, 3,000 prompts
batches of up to 974 and 1,115 prompts in two runs
For the per-prompt request functions a large batch doesn't help: requests are sent 32 at a time (_MAX_CONCURRENT_REQUESTS_PER_BATCH). It does cost something, because RemoteModelHandler retries the whole batch when one request fails, which re-sends the prompts that already succeeded.
@claudevdm asked about this on #40239 ("Should we set a default max batch size so that we dont exceed the api batch size limits?", #40239 (comment)) and it wasn't picked up.
Proposal: default max_batch_size to 32 in both handlers, and to 2,048 with embedding_from_string, never below a min_batch_size the user set. An explicit max_batch_size keeps working as it does now. I have this ready with tests and will open the PR. The Gemini per-prompt requests from #40914 first ship in 2.79.0, so it would be good to settle the default before that release.
Activity
tannnmayy commentedon Nov 15, 2026
.take-issue