vllm.entrypoints.openai.chat_completion.batch_serving
¶
Classes:
-
OpenAIServingChatBatch–Extends OpenAIServingChat with the /v1/chat/completions/batch endpoint.
OpenAIServingChatBatch
¶
Bases: OpenAIServingChat
Extends OpenAIServingChat with the /v1/chat/completions/batch endpoint.
Processes N conversations from a single request concurrently and returns one choice per conversation indexed 0, 1, ..., N-1.
Methods:
-
chat_completion_full_generator_batch–Handle batched (non-streaming) chat completions.
-
create_batch_chat_completion–Batch Chat Completion endpoint (/v1/chat/completions/batch).
-
render_batch_chat_request–Validate the model and preprocess a batched chat completion request.
chat_completion_full_generator_batch(request, generators, request_id, model_name, all_conversations, tokenizer, request_metadata, parser_cls=None, mm_token_counts=None)
async
¶
Handle batched (non-streaming) chat completions.
Fans out N generators (one per conversation in the batch), collects
the final output for each, and assembles a single
ChatCompletionResponse whose choices are indexed 0,...,N-1.
Tool-use and streaming are rejected upstream by the
check_batch_mode validator, so neither needs to be handled here.
create_batch_chat_completion(request, raw_request=None)
async
¶
Batch Chat Completion endpoint (/v1/chat/completions/batch).
Processes N conversations from a single request concurrently and returns one choice per conversation indexed 0, 1, ..., N-1. Streaming, tool use, and beam search are not supported.
render_batch_chat_request(request)
async
¶
Validate the model and preprocess a batched chat completion request.
Performs engine-aware checks then delegates per-conversation preprocessing to OnlineRenderer, validating the chat template once for the whole batch.
Returns:
-
tuple[list[ChatCompletionRequest], list[list[ConversationMessage]], list[EngineInput]] | ErrorResponse–A tuple of (single_requests, all_conversations, engine_prompts) on
-
tuple[list[ChatCompletionRequest], list[list[ConversationMessage]], list[EngineInput]] | ErrorResponse–success — one entry per conversation — or an ErrorResponse on
-
tuple[list[ChatCompletionRequest], list[list[ConversationMessage]], list[EngineInput]] | ErrorResponse–failure. The renderer adjusts
single_requestsin place, so -
tuple[list[ChatCompletionRequest], list[list[ConversationMessage]], list[EngineInput]] | ErrorResponse–sampling must read them rather than rebuilding from
request.
_sum_or_none(counts)
¶
Sum per-prompt counts; None unless every prompt reported one.