Skip to content

[Bug]: Gemini and OpenAI model handlers set no default max_batch_size; default embedding requests exceed the API's 2,048-input limit #41360

Open

Description

@tannnmayy

What happened?

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.

cc @jrmccluskey

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Prism Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner

Activity

  1. tannnmayy commented on Nov 15, 2026

    @tannnmayy
    ContributorAuthor

    .take-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions