Skip to content

vllm.entrypoints.launchers.run_batch

Classes:

Functions:

BatchFrontendArgs

Bases: BaseFrontendArgs

Arguments for the batch runner frontend.

Attributes:

  • enable_metrics (bool) –

    Enable Prometheus metrics

  • host (str | None) –

    Host name for the Prometheus metrics server

  • input_file (str | None) –

    The path or url to a single input file. Currently supports local file

  • max_inflight (int | None) –

    Maximum number of requests queued at the engine at once. Responses are

  • output_file (str | None) –

    The path or url to a single output file. Currently supports

  • output_tmp_dir (str | None) –

    Directory for staging a URL input, a piped input, or the output before

  • port (int) –

    Port number for the Prometheus metrics server

  • url (str) –

    [DEPRECATED] Host name for the Prometheus metrics server

enable_metrics = False class-attribute instance-attribute

Enable Prometheus metrics

host = None class-attribute instance-attribute

Host name for the Prometheus metrics server (only needed if enable-metrics is set).

input_file = None class-attribute instance-attribute

The path or url to a single input file. Currently supports local file paths, or the http protocol (http or https). If a URL is specified, the file should be available via HTTP GET.

max_inflight = None class-attribute instance-attribute

Maximum number of requests queued at the engine at once. Responses are written in input order, so up to 16 times this many finished responses may be held behind a slow request. Defaults to twice max_num_seqs across all data-parallel engines, at least 1024. --max-num-queued-reqs and --max-num-queued-tokens are ignored.

output_file = None class-attribute instance-attribute

The path or url to a single output file. Currently supports local file paths, or web (http or https) urls. If a URL is specified, the file should be available via HTTP PUT.

output_tmp_dir = None class-attribute instance-attribute

Directory for staging a URL input, a piped input, or the output before it is uploaded to a URL. When unset, piped input and output are held in memory and URL input is downloaded to the system temporary directory.

port = 8000 class-attribute instance-attribute

Port number for the Prometheus metrics server (only needed if enable-metrics is set).

url = '0.0.0.0' class-attribute instance-attribute

[DEPRECATED] Host name for the Prometheus metrics server (only needed if enable-metrics is set). Use --host instead.

BatchRequestInput

Bases: OpenAIBaseModel

The per-line object of the batch input file.

url selects the request type that body is parsed as.

BatchRequestOutput

Bases: OpenAIBaseModel

The per-line object of the batch output and error files

BatchTranscriptionRequest

Bases: TranscriptionRequest

Batch transcription request that uses file_url instead of file.

This class extends TranscriptionRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.

Methods:

validate_no_file(data) classmethod

Ensure file field is not provided in batch requests.

BatchTranslationRequest

Bases: TranslationRequest

Batch translation request that uses file_url instead of file.

This class extends TranslationRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.

Methods:

validate_no_file(data) classmethod

Ensure file field is not provided in batch requests.

EndpointConfig

Bases: TypedDict

How a batch request URL is matched to the handler that serves it.

batch_output_writer(path_or_url, output_tmp_dir) async

Yield a file that receives responses in input order.

A local file holds the responses for a prefix of the input if the run fails. A URL destination is staged and uploaded only once the batch completes.

build_endpoint_registry(engine_client, args) async

Build the endpoint registry with all serving objects and handler configurations.

Parameters:

Returns:

dispatch_batch(input_file, output_file, endpoint_registry, tracker, max_inflight, window=None, engine_client=None) async

Run every request with at most max_inflight alive at once.

Responses are written in input order, with at most window requests, max_inflight by default, dispatched but not yet written. The first request to raise, rather than return an error response, cancels the rest, as does an error response once engine_client is dead.

download_bytes_from_url(url, allowed_media_domains=None) async

Download data from a URL or decode from a data URL.

Parameters:

  • url

    (str) –

    Either an HTTP/HTTPS URL or a data URL (data:...;base64,...)

  • allowed_media_domains

    (list[str] | None, default: None ) –

    If set, only HTTP/HTTPS URLs whose hostname is in this list are permitted. data: URLs are not subject to this restriction.

Returns:

  • bytes –

    Data as bytes

handle_endpoint_request(request, config)

Generic handler for endpoint requests.

Parameters:

Returns:

ignore_admission_limits(args)

Clear the engine limits that reject requests with a 503.

They let an online client retry on another instance or meet a TTFT target; run-batch could only write each rejected request out as an error.

is_same_local_file(input_file, output_file)

Whether both paths name the same regular file; only those can be truncated.

make_transcription_wrapper(is_translation, allowed_media_domains=None)

Factory function to create a wrapper for transcription/translation handlers. The wrapper converts BatchTranscriptionRequest or BatchTranslationRequest to TranscriptionRequest or TranslationRequest and calls the appropriate handler.

Parameters:

  • is_translation

    (bool) –

    If True, process as translation; otherwise process as transcription

  • allowed_media_domains

    (list[str] | None, default: None ) –

    If set, only URLs from these domains are permitted for HTTP/HTTPS fetches.

Returns:

  • WrapperFn –

    A function that takes a handler and returns a wrapped handler

open_batch_input(path_or_url, tmp_dir) async

Yield the batch as a seekable text file, so it can be read twice.

A non-seekable source is staged via staging_file. A URL is downloaded to a file, since the in-memory fetch is capped at the media download limit.

run_one_request(request_json, endpoint_registry) async

Route a single line of the batch to its endpoint handler.

staging_file(tmp_dir, prefix)

In-memory buffer, or a temporary file when a directory is given.

upload_data(output_url, data_or_file, from_file) async

Upload a local file to a URL. output_url: The URL to upload the file to. data_or_file: Either the data to upload or the path to the file to upload. from_file: If True, data_or_file is the path to the file to upload.

url_matches(endpoint_url, url)

Unversioned endpoints (/score, /rerank) match by suffix; others exactly.

validate_batch(input_file)

Parse every request and return the count; requests are re-parsed when run.