Skip to content

[bot] LiteLLM: batch_completion (and batch_completion_models) not instrumented #755

Description

@braintrust-bot

Summary

LiteLLM's Python SDK ships a documented batch-inference execution surface — litellm.batch_completion() — which fans a single set of messages (or a list of prompt lists) out to concurrent completion() calls across one or more models and returns the list of responses. The Braintrust LiteLLM integration (py/src/braintrust/integrations/litellm/) instruments 18 top-level LiteLLM entry points (completion/acompletion, text_completion/atext_completion, responses/aresponses, image_generation/aimage_generation, embedding/aembedding, moderation/amoderation, speech/aspeech, transcription/atranscription, rerank/arerank), but has no patcher for batch_completion, batch_completion_models, or batch_completion_models_all_responses. Calls made through these batch entry points produce zero Braintrust spans — no input/output, no token usage, no cost.

What is missing

LiteLLM function Description Instrumented?
litellm.completion / .acompletion Single-call chat completion Yes
litellm.batch_completion Fans a list of message lists out to concurrent completion() calls against one model, returns list of responses No
litellm.batch_completion_models Parallel calls across multiple models, returns first response No
litellm.batch_completion_models_all_responses Parallel calls across multiple models, returns all responses No

Source of the function list: litellm/batch_completion/main.py and the Batching Completion() docs:

from litellm import batch_completion

responses = batch_completion(
    model="claude-2",
    messages=[
        [{"role": "user", "content": "good morning?"}],
        [{"role": "user", "content": "what's the time?"}],
    ],
)

Each element of messages is dispatched as an independent completion()-shaped call (concurrently, via a thread pool, max_workers configurable), so this is a distinct execution surface from the already-instrumented single-shot completion/acompletion, not just a client-side loop the user writes themselves — the concurrency and result aggregation happen inside LiteLLM.

Braintrust docs status

not_found. The Braintrust LiteLLM integration page states Braintrust "patches LiteLLM's top-level call entry points and creates an LLM-typed span per call," and explicitly lists the entry points covered: completion, acompletion, text_completion, atext_completion, responses, aresponses, image_generation, aimage_generation, embedding, aembedding, moderation, amoderation, speech, aspeech, transcription, atranscription, rerank, arerank. batch_completion and its variants are not mentioned anywhere on the page.

Upstream sources

Local repo files inspected

  • py/src/braintrust/integrations/litellm/patchers.py — defines LiteLLMCompletionPatcher through LiteLLMArerankPatcher (18 patchers total); no batch_completion patcher exists. Grep for batch_completion across the entire litellm/ integration directory returns zero matches.
  • py/src/braintrust/integrations/litellm/integration.pyLiteLLMIntegration.patchers = _ALL_LITELLM_PATCHERS, sourced entirely from patchers.py.
  • py/src/braintrust/integrations/litellm/tracing.py — wrapper implementations for all 18 patched entry points; no batch_completion wrapper.
  • py/src/braintrust/integrations/litellm/test_litellm.pytest_litellm_async_parallel_requests exercises concurrent acompletion() calls via asyncio.gather, not the batch_completion API; no test references batch_completion.
  • py/pyproject.toml [tool.braintrust.matrix.litellm] (line 398-402): latest = "litellm==1.100.0", floor "1.74.0" = "litellm==1.74.0" — both versions ship batch_completion.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions