[Feature Request]: Send the requests in a batch concurrently in AnthropicModelHandler, like the OpenAI and Gemini handlers
メンテナーはふだん 2 日以内に返信
評価
この issue はまだ評価されていません。
説明
What would you like to happen?
The Anthropic Messages API takes one conversation per request, so message_from_string and message_from_conversation in apache_beam/ml/inference/anthropic_inference.py send one request per element. They send them one after another (lines 126 and 156), so a batch takes the sum of all its request times.
The OpenAI and Gemini handlers have the same one-request-per-element shape, but send the requests of a batch concurrently through _fan_out, a bounded thread pool capped at _MAX_CONCURRENT_REQUESTS_PER_BATCH = 32 (added in #40239 and #40914).
With a fake client where each call takes 0.5 s:
import time
from unittest import mock
from apache_beam.ml.inference.anthropic_inference import message_from_string
class Messages:
def create(self, **kwargs):
time.sleep(0.5)
return 'response'
client = mock.Mock(messages=Messages())
start = time.time()
message_from_string('claude-haiku-4-5', ['prompt'] * 8, client, {})
print(f'{time.time() - start:.1f}s')
Output: 4.0s, with at most 1 request in flight. chat_completion_from_string in the OpenAI handler takes 0.5 s for the same batch.
Proposal: use the same _fan_out pattern in both Anthropic request functions. Results stay in input order, and if any request fails, the remaining ones are cancelled and the first error is raised, so Beam's existing retry and throttling handle the batch as they do now. The anthropic client uses the same httpx-based client design as the openai client, which is shared across threads in the OpenAI handler.
#41196 is changing the same two functions, so I'll wait for it to merge and build on it.
I'm willing to work on this and open a PR.
Version: master at 0c549fa6c8 (2.79.0.dev)
Issue Priority
Priority: 2 (default / most feature requests 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
- 主要言語
- Java
- スター
- 8.7k
- フォーク
- 4.8k
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 445
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/beam のほかの issue
-
awaiting triage java new feature P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
[Bug]: [Python] BigTableEnrichmentHandler coerces None lookup keys to literal b'None' and formats blank key name on KeyError対応中かも @shikhabhadoria が 6 日前に担当しました。 オープンio P2 python
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/beam#41346 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Release notes links wrong対応中かも @schizophrenicmaniac が 20 日前に担当しました。 オープンbug P3
難易度 1/5 1時間未満 初心者へのやさしさ 67/100
apache/beam#41197 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/beam#39624 · リアクション 2 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: PubsubIO used in batch incorrect batch cutoff size対応中かも @1fanwang が 98 日前に担当しました。 オープンbug io P3 pinned pubsub
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/beam#28011 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
`ovsx verify` fails for a version older than the 100 newest of an extension対応中かも @trivikr が今日担当しました。 オープンcli
難易度 2/5 1〜3時間 初心者へのやさしさ 81/100
eclipse-openvsx/openvsx#2482 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
Magic-team-jvav/confluence#281 ·
-
area/dependencies area/dependencies/js backport/26.6 backport/26.8 kind/cve severity/medium source/scan-dependencies status/triage
難易度 1/5 1時間未満 初心者へのやさしさ 67/100
メンテナーはふだん 2 日以内に返信
-
[DEFECT] AsciiDoc builders write a stray ## before every schema member when the namespace prefixes file binds the schema's own namespace対応中かも @Beehtrix が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cimug-org/CIMTool#427 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
userRaised
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
eclipse-openj9/openj9#25285 ·
メンテナーはふだん 1 日以内に返信