vllm.entrypoints.launchers.run_batch
¶
Classes:
-
BatchFrontendArgs–Arguments for the batch runner frontend.
-
BatchRequestInput–The per-line object of the batch input file.
-
BatchRequestOutput–The per-line object of the batch output and error files
-
BatchTranscriptionRequest–Batch transcription request that uses file_url instead of file.
-
BatchTranslationRequest–Batch translation request that uses file_url instead of file.
-
EndpointConfig–How a batch request URL is matched to the handler that serves it.
Functions:
-
batch_output_writer–Yield a file that receives responses in input order.
-
build_endpoint_registry–Build the endpoint registry with all serving objects and handler configurations.
-
dispatch_batch–Run every request with at most
max_inflightalive at once. -
download_bytes_from_url–Download data from a URL or decode from a data URL.
-
handle_endpoint_request–Generic handler for endpoint requests.
-
ignore_admission_limits–Clear the engine limits that reject requests with a 503.
-
is_same_local_file–Whether both paths name the same regular file; only those can be truncated.
-
make_transcription_wrapper–Factory function to create a wrapper for transcription/translation handlers.
-
open_batch_input–Yield the batch as a seekable text file, so it can be read twice.
-
run_one_request–Route a single line of the batch to its endpoint handler.
-
staging_file–In-memory buffer, or a temporary file when a directory is given.
-
upload_data–Upload a local file to a URL.
-
url_matches–Unversioned endpoints (/score, /rerank) match by suffix; others exactly.
-
validate_batch–Parse every request and return the count; requests are re-parsed when run.
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
Source code in vllm/entrypoints/launchers/run_batch.py
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.
Source code in vllm/entrypoints/launchers/run_batch.py
BatchRequestOutput
¶
Bases: OpenAIBaseModel
The per-line object of the batch output and error files
Source code in vllm/entrypoints/launchers/run_batch.py
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–Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/launchers/run_batch.py
validate_no_file(data)
classmethod
¶
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/launchers/run_batch.py
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–Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/launchers/run_batch.py
validate_no_file(data)
classmethod
¶
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/launchers/run_batch.py
EndpointConfig
¶
Bases: TypedDict
How a batch request URL is matched to the handler that serves it.
Source code in vllm/entrypoints/launchers/run_batch.py
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.
Source code in vllm/entrypoints/launchers/run_batch.py
build_endpoint_registry(engine_client, args)
async
¶
Build the endpoint registry with all serving objects and handler configurations.
Parameters:
-
(engine_client¶EngineClient) –The engine client
-
(args¶Namespace) –Command line arguments
Returns:
-
dict[str, EndpointConfig]–Dictionary mapping endpoint keys to their configurations
Source code in vllm/entrypoints/launchers/run_batch.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | |
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.
Source code in vllm/entrypoints/launchers/run_batch.py
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 | |
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
Source code in vllm/entrypoints/launchers/run_batch.py
handle_endpoint_request(request, config)
¶
Generic handler for endpoint requests.
Parameters:
-
(request¶BatchRequestInput) –The batch request input
-
(config¶EndpointConfig) –The endpoint's URL matching rule and handler
Returns:
-
Awaitable[BatchRequestOutput] | None–Awaitable[BatchRequestOutput] if the request was handled,
-
Awaitable[BatchRequestOutput] | None–None if URL didn't match
Source code in vllm/entrypoints/launchers/run_batch.py
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.
Source code in vllm/entrypoints/launchers/run_batch.py
is_same_local_file(input_file, output_file)
¶
Whether both paths name the same regular file; only those can be truncated.
Source code in vllm/entrypoints/launchers/run_batch.py
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
Source code in vllm/entrypoints/launchers/run_batch.py
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.
Source code in vllm/entrypoints/launchers/run_batch.py
run_one_request(request_json, endpoint_registry)
async
¶
Route a single line of the batch to its endpoint handler.
Source code in vllm/entrypoints/launchers/run_batch.py
staging_file(tmp_dir, prefix)
¶
In-memory buffer, or a temporary file when a directory is given.
Source code in vllm/entrypoints/launchers/run_batch.py
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.
Source code in vllm/entrypoints/launchers/run_batch.py
url_matches(endpoint_url, url)
¶
Unversioned endpoints (/score, /rerank) match by suffix; others exactly.
Source code in vllm/entrypoints/launchers/run_batch.py
validate_batch(input_file)
¶
Parse every request and return the count; requests are re-parsed when run.