vllm.benchmarks.datasets
¶
Modules:
-
create_txt_slices_dataset–Convert a plain-text file (local path or URL) into a JSONL dataset
-
datasets–This module defines a framework for sampling benchmark requests from various
-
utils–Shared utilities for benchmark dataset sampling.
Classes:
-
AIMODataset–Dataset class for processing a AIMO dataset with reasoning questions.
-
ASRDataset–Dataset class for processing a ASR dataset for transcription.
-
BFCLDataset–Berkeley Function Calling Leaderboard dataset.
-
BenchmarkDataset– -
BlazeditDataset–Blazedit Dataset.
-
BurstGPTDataset–Implements the BurstGPT dataset. Loads data from a CSV file and generates
-
ConversationDataset–Dataset for text-only conversation data.
-
CustomAudioDataset–Custom dataset for audio benchmarking. Loads data from a JSONL file. E.g.,
-
CustomDataset–Implements the Custom dataset. Loads data from a JSONL file and generates
-
CustomImageDataset–Implements the Custom image dataset. Loads data from a JSONL file and generates
-
HuggingFaceDataset–Base class for datasets hosted on HuggingFace.
-
InstructCoderDataset–InstructCoder Dataset.
-
MLPerfDataset–MLPerf Inference Dataset.
-
MMStarDataset–Lin-Chen/MMStar: https://huggingface.co/datasets/Lin-Chen/MMStar
-
MMVUDataset–MMVU Dataset.
-
MTBenchDataset–MT-Bench Dataset.
-
MultiModalConversationDataset–Dataset for multimodal conversation data.
-
NextEditPredictionDataset–Dataset class for processing a Next Edit Prediction dataset.
-
RandomDataset–Synthetic text-only dataset for serving/throughput benchmarks.
-
RandomDatasetForReranking–Random dataset specialized for the needs of scoring:
-
RandomMultiModalDataset–Synthetic multimodal dataset (text + images) that extends RandomDataset.
-
SampleRequest–Represents a single inference request for benchmarking.
-
ShareGPTDataset–Implements the ShareGPT dataset. Loads data from a JSON file and generates
-
SpecBench–Implements the SpecBench dataset: https://github.com/hemingkx/Spec-Bench
-
VisionArenaDataset–Vision Arena Dataset.
Functions:
-
add_random_dataset_base_args–Add CLI arguments for base random dataset options.
-
add_random_multimodal_dataset_args–Add CLI arguments for random multimodal dataset options.
-
gen_prompt_decode_to_target_len–Ensure decoded-then-encoded prompt length matches the target token length.
-
is_valid_sequence–Validate a sequence based on prompt and output lengths.
-
process_audio–Process a single audio input and return a (array, sample_rate) tuple.
-
process_image–Process a single image input and return a multimedia content dictionary.
-
process_video–Process a single video input and return a multimedia content dictionary.
AIMODataset
¶
ASRDataset
¶
Bases: HuggingFaceDataset
Dataset class for processing a ASR dataset for transcription. Tested on the following set:
+---------------------------+----------------------------------------+--------------------------+-----------------------------+ | Dataset | Domain | Speaking Style | hf-subset | +---------------------------+----------------------------------------+--------------------------+-----------------------------+ | TED-LIUM | TED talks | Oratory | release1, release2, release3| | | | | release3-speaker-adaptation | | VoxPopuli | European Parliament | Oratory | en, de, it, fr, ... | | LibriSpeech | Audiobook | Narrated | "LIUM/tedlium" | | GigaSpeech | Audiobook, podcast, YouTube | Narrated, spontaneous | xs, s, m, l, xl, dev, test | | SPGISpeech | Financial meetings | Oratory, spontaneous | S, M, L, dev, test | | Earnings22-Cleaned-AA | Long form earnings calls | Prepared remarks, Q&A | test | | Earnings22-Tiny-Filtered | Earnings calls | Prepared remarks, Q&A | validation | | AMI | Meetings | Spontaneous | ihm, sdm | +---------------------------+----------------------------------------+--------------------------+-----------------------------+
BFCLDataset
¶
Bases: HuggingFaceDataset
Berkeley Function Calling Leaderboard dataset.
https://huggingface.co/datasets/gorilla-llm/Berkeley-Function-Calling-Leaderboard
BFCL ships one JSON-lines file per category at the repo root (e.g.
BFCL_v3_simple.json, BFCL_v3_live_simple.json) rather than a
single HuggingFace split. Each record has {id, question, function}
where function uses a non-OpenAI schema dialect ("type": "dict").
This dataset loader
- downloads the selected per-category files via
hf_hub_downloadand interleaves rows round-robin so sampling is balanced - translates BFCL function schemas to OpenAI tool format
- sets
SampleRequest.chat_messagesdirectly and attachestools/tool_choiceviaSampleRequest.request_overrides, producing production-alike tool calling traffic when used with anopenai-chatbackend
Methods:
-
load_data–Defer loading to
samplewhere categories are known.
BenchmarkDataset
¶
Bases: ABC
Methods:
-
__init__–Initialize the BenchmarkDataset with an optional dataset path and random
-
apply_multimodal_chat_transformation–Transform a prompt and optional multimodal content into a chat format.
-
get_lora_request–Select a LoRA request using the specified assignment strategy.
-
get_random_lora_request–Optionally select a random LoRA request.
-
get_round_robin_lora_request–Optionally select a LoRA request using deterministic round-robin.
-
load_data–Load data from the dataset path into self.data.
-
maybe_oversample_requests–Oversamples the list of requests if its size is less than the desired
-
sample–Abstract method to generate sample requests from the dataset.
__init__(dataset_path=None, random_seed=DEFAULT_SEED, disable_shuffle=False, **kwargs)
¶
Initialize the BenchmarkDataset with an optional dataset path and random seed.
Parameters:
-
(dataset_path¶Optional[str], default:None) –Path to the dataset. If None, it indicates that a default or random dataset might be used.
-
(random_seed¶int, default:DEFAULT_SEED) –Seed value for reproducible shuffling or sampling. Defaults to DEFAULT_SEED.
-
(disable_shuffle¶bool, default:False) –If True, keep the dataset in its original order instead of shuffling it.
apply_multimodal_chat_transformation(prompt, mm_content=None)
¶
Transform a prompt and optional multimodal content into a chat format. This method is used for chat models that expect a specific conversation format.
get_lora_request(index, max_loras=None, lora_path=None, lora_assignment='random')
staticmethod
¶
Select a LoRA request using the specified assignment strategy.
Parameters:
-
(index¶int) –The request index (used for round-robin).
-
(max_loras¶Optional[int], default:None) –The maximum number of LoRAs available.
-
(lora_path¶Optional[str], default:None) –Path to the LoRA parameters on disk.
-
(lora_assignment¶str, default:'random') –Strategy for LoRA selection. 'random' (default) or 'round-robin'.
Returns:
-
LoRARequest | None–A new
LoRARequest -
LoRARequest | None–(or
Noneif not applicable).
get_random_lora_request(max_loras=None, lora_path=None)
staticmethod
¶
Optionally select a random LoRA request.
This method is used when LoRA parameters are provided. It randomly selects a LoRA based on max_loras.
Parameters:
-
(max_loras¶Optional[int], default:None) –The maximum number of LoRAs available. If
None, LoRA is not used. -
(lora_path¶Optional[str], default:None) –Path to the LoRA parameters on disk. If
None, LoRA is not used.
Returns:
-
LoRARequest | None–A new
LoRARequest -
LoRARequest | None–(or
Noneif not applicable).
get_round_robin_lora_request(index, max_loras=None, lora_path=None)
staticmethod
¶
Optionally select a LoRA request using deterministic round-robin.
This method cycles through LoRA IDs in order based on the request index, providing reproducible LoRA assignment.
Parameters:
-
(index¶int) –The request index used for round-robin selection.
-
(max_loras¶Optional[int], default:None) –The maximum number of LoRAs available. If
None, LoRA is not used. -
(lora_path¶Optional[str], default:None) –Path to the LoRA parameters on disk. If
None, LoRA is not used.
Returns:
-
LoRARequest | None–A new
LoRARequest -
LoRARequest | None–(or
Noneif not applicable).
load_data()
¶
Load data from the dataset path into self.data.
This method must be overridden by subclasses since the method to load data will vary depending on the dataset format and source.
Raises:
-
NotImplementedError–If a subclass does not implement this method.
maybe_oversample_requests(requests, num_requests, request_id_prefix='', no_oversample=False)
¶
Oversamples the list of requests if its size is less than the desired number.
Parameters:
-
(requests¶List[SampleRequest]) –The current list of sampled requests.
-
(num_requests¶int) –The target number of requests.
-
(request_id_prefix¶str, default:'') –The prefix applied to generated request identifiers.
-
(no_oversample¶bool, default:False) –If True, return the requests unchanged instead of oversampling up to num_requests.
sample(tokenizer, num_requests, request_id_prefix='', no_oversample=False, **kwargs)
abstractmethod
¶
Abstract method to generate sample requests from the dataset.
Subclasses must override this method to implement dataset-specific logic for generating a list of SampleRequest objects.
Parameters:
-
(tokenizer¶TokenizerLike) –The tokenizer to be used for processing the dataset's text.
-
(num_requests¶int) –The number of sample requests to generate.
-
(request_id_prefix¶str, default:'') –The prefix of request_id.
-
(no_oversample¶bool, default:False) –If True, do not oversample the dataset to reach num_requests.
Returns:
-
list[SampleRequest]–list[SampleRequest]: A list of sample requests generated from the
-
list[SampleRequest]–dataset.
BlazeditDataset
¶
Bases: HuggingFaceDataset
Blazedit Dataset. https://github.com/ise-uiuc/blazedit
5k char version: vdaita/edit_5k_char 10k char version: vdaita/edit_10k_char
BurstGPTDataset
¶
Bases: BenchmarkDataset
Implements the BurstGPT dataset. Loads data from a CSV file and generates sample requests based on synthetic prompt generation. Only rows with Model "GPT-4" and positive response tokens are used.
ConversationDataset
¶
CustomAudioDataset
¶
Bases: CustomDataset
Custom dataset for audio benchmarking. Loads data from a JSONL file. E.g.,
Supports both: - Dedicated ASR models (e.g. Whisper) via openai-audio & /v1/audio/transcriptions - Chat-based audio models (e.g. Qwen2-Audio) via openai-chat & /v1/chat/completions
CustomDataset
¶
Bases: BenchmarkDataset
Implements the Custom dataset. Loads data from a JSONL file and generates sample requests based on conversation turns. E.g.,
{"prompt": "What is the capital of India?", "output_tokens": 10}
{"prompt": "What is the capital of Iran?", "output_tokens": 1520}
{"prompt": "What is the capital of China?", "output_tokens": 819}
CustomImageDataset
¶
Bases: CustomDataset
Implements the Custom image dataset. Loads data from a JSONL file and generates sample requests based on conversation turns. E.g.,
{
"prompt": "How many red blocks in the given images?",
"image_files": ["path/to/image1.png", "path/to/image2.png"],
}
{
"prompt": "Which country has the most pokemons based on the given graphs?",
"image_files": ["path/to/image.png"],
}
{
"content": [
{"type": "text", "text": "Compare these images: "},
{"type": "image", "image": "path/to/image1.png"},
{"type": "text", "text": " and "},
{"type": "image_url", "image_url": {"url": "path/to/image2.png"}},
],
}
This is used to benchmark multimodal LLMs on arbitrary datasets.
HuggingFaceDataset
¶
Bases: BenchmarkDataset
Base class for datasets hosted on HuggingFace.
Methods:
-
load_data–Load data from HuggingFace datasets.
load_data()
¶
Load data from HuggingFace datasets.
InstructCoderDataset
¶
Bases: HuggingFaceDataset
InstructCoder Dataset. https://huggingface.co/datasets/likaixin/InstructCoder
InstructCoder is the dataset designed for general code editing. It consists of 114,239 instruction-input-output triplets, and covers multiple distinct code editing scenario.
MLPerfDataset
¶
Bases: HuggingFaceDataset
MLPerf Inference Dataset.
Dataset on HF: https://huggingface.co/datasets/mgoin/mlperf-inference-llama2-data https://huggingface.co/datasets/mgoin/mlperf-inference-llama3.1-data
Each record contains
- "system_prompt": system role instruction.
- "question": user question.
- "output": reference answer.
We combine the system prompt and question into a chat-formatted prompt (using the tokenizer's chat template) and set the expected output length to the tokenized length of the provided reference answer.
MMStarDataset
¶
Bases: HuggingFaceDataset
Lin-Chen/MMStar: https://huggingface.co/datasets/Lin-Chen/MMStar refer to: https://github.com/sgl-project/SpecForge/pull/106
MMVUDataset
¶
MTBenchDataset
¶
Bases: HuggingFaceDataset
MT-Bench Dataset. https://huggingface.co/datasets/philschmid/mt-bench
We create a single turn dataset for MT-Bench. This is similar to Spec decoding benchmark setup in vLLM https://github.com/vllm-project/vllm/blob/9d98ab5ec/examples/offline_inference/eagle.py#L14-L18
MultiModalConversationDataset
¶
NextEditPredictionDataset
¶
RandomDataset
¶
Bases: BenchmarkDataset
Synthetic text-only dataset for serving/throughput benchmarks.
Strategy: - Sample input/output token lengths per request from integer-uniform ranges around configured means (controlled by range_ratio). - Prepend a fixed random prefix of length prefix_len. - Generate the remaining tokens as a reproducible sequence: (offset + index + arange(input_len)) % vocab_size. - Decode then re-encode/truncate to ensure prompt token counts match. - Uses numpy.default_rng seeded with random_seed for reproducible sampling.
Methods:
-
generate_token_sequence–Returns (prompt, total_input_len).
-
get_prefix–Get the prefix for the dataset.
generate_token_sequence(*, tokenizer, prefix_token_ids, prefix_len, vocab_size, input_len, offset, index, allowed_tokens)
¶
Returns (prompt, total_input_len).
NOTE: After decoding the prompt we have to encode and decode it again. This is done because in some cases N consecutive tokens give a string tokenized into != N number of tokens. For example for GPT2Tokenizer: [6880, 6881] -> ['Ġcalls', 'here'] -> [1650, 939, 486] -> ['Ġcall', 'sh', 'ere'] To avoid uncontrolled change of the prompt length, the encoded sequence is truncated before being decoded again.
get_prefix(tokenizer, allowed_tokens, prefix_len)
¶
Get the prefix for the dataset.
RandomDatasetForReranking
¶
Bases: RandomDataset
Random dataset specialized for the needs of scoring: - Batches of inputs - Inputs composed of pairs
RandomMultiModalDataset
¶
Bases: RandomDataset
Synthetic multimodal dataset (text + images) that extends RandomDataset.
Status: - Images: supported via synthetic RGB data. - Video: supported via synthetic RGB data. - Audio: not yet supported.
Sampling overview:
1) Number of items per request is sampled uniformly from the integer range
[floor(n·(1−r)), ceil(n·(1+r))], where n is the base count and r is
num_mm_items_range_ratio in [0, 1]. r=0 keeps it fixed; r=1 allows 0.
The maximum is further clamped to the sum of per-modality limits.
2) Each item’s modality and shape is sampled from bucket_config, a dict
mapping (height, width, num_frames) → probability. We treat
num_frames=1 as image and num_frames > 1 as video.
Entries with zero probability are removed and the rest are renormalized
to sum to 1.
3) Per-modality hard caps are enforced via limit_mm_per_prompt.
When a modality reaches its cap, all of its buckets are excluded and the
remaining probabilities are renormalized.
Example bucket configuration:
{(256, 256, 1): 0.5, (720, 1280, 1): 0.4, (720, 1280, 16): 0.1}
- Two image buckets (num_frames=1) and one video bucket
(num_frames=16).
OBS.: Only image sampling is supported for now.
Methods:
-
generate_mm_item–Create synthetic images and videos and
-
generate_synthetic_image–Generate synthetic PIL image with random RGB values.
-
generate_synthetic_video–Generate synthetic video with random values.
-
get_mm_item_iterator–Iterator over the multimodal items for each request
-
get_mm_item_sampling_params–Get the sampling parameters for the multimodal items.
-
map_config_to_modality–Map the configuration to the modality.
-
normalize_bucket_config–Remove zero probability entries
generate_mm_item(mm_item_config, video_encode_fps=DEFAULT_VIDEO_ENCODE_FPS)
¶
Create synthetic images and videos and apply process_image/process_video respectively. This follows the OpenAI API chat completions https://github.com/openai/openai-python
generate_synthetic_image(width, height)
¶
Generate synthetic PIL image with random RGB values.
NOTE: iid pixel sampling results in worst-case compression (good for stressing I/O), but very unlike real photos. We could consider a “low-freq” mode (e.g., noise blur) to emulate network realism instead of max stress.
generate_synthetic_video(width, height, num_frames, encode_fps=DEFAULT_VIDEO_ENCODE_FPS)
¶
Generate synthetic video with random values.
Creates a video with random pixel values, encodes it to MP4 format, and returns the content as bytes.
encode_fps is container metadata only; the target model may
resample at its own native fps, so processed frame count can differ.
get_mm_item_iterator(min_num_mm_items, max_num_mm_items, bucket_config, limit_mm_per_prompt)
¶
Iterator over the multimodal items for each request whose size is between min_num_mm_items and max_num_mm_items.
Loop over the bucket config and sample a multimodal item. Loop until the number of multimodal items sampled is equal to request_num_mm_items or limit of multimodal items per prompt for all modalities is reached.
Note:
- This function operates on a per-request shallow copy of
bucket_config (tuple->float). The original dict passed to
sample is not mutated. If this ever changes, a test
is implemented and will fail.
get_mm_item_sampling_params(base_items_per_request, num_mm_items_range_ratio, limit_mm_per_prompt, bucket_config)
¶
Get the sampling parameters for the multimodal items.
map_config_to_modality(config)
¶
Map the configuration to the modality.
normalize_bucket_config(bucket_config)
¶
Remove zero probability entries and normalize the bucket config to sum to 1.
SampleRequest
dataclass
¶
Represents a single inference request for benchmarking.
ShareGPTDataset
¶
Bases: BenchmarkDataset
Implements the ShareGPT dataset. Loads data from a JSON file and generates sample requests based on conversation turns.
SpecBench
¶
Bases: CustomDataset
Implements the SpecBench dataset: https://github.com/hemingkx/Spec-Bench Download the dataset using: wget https://raw.githubusercontent.com/hemingkx/Spec-Bench/refs/heads/main/data/spec_bench/question.jsonl
VisionArenaDataset
¶
add_random_dataset_base_args(parser_or_group)
¶
Add CLI arguments for base random dataset options.
This function adds arguments needed for: - random (random dataset) - random-mm (random multimodal dataset) - random-rerank (random dataset for reranking)
Parameters:
-
(parser_or_group¶FlexibleArgumentParser | _ArgumentGroup) –Either a parser or an argument group to add arguments to.
add_random_multimodal_dataset_args(parser_or_group)
¶
Add CLI arguments for random multimodal dataset options.
This function adds arguments needed for: - random-mm (random multimodal dataset)
Parameters:
-
(parser_or_group¶FlexibleArgumentParser | _ArgumentGroup) –Either a parser or an argument group to add arguments to.
gen_prompt_decode_to_target_len(tokenizer, token_sequence, target_token_len, max_retry=10, add_special_tokens=False, rng=None)
¶
Ensure decoded-then-encoded prompt length matches the target token length.
This function decodes an initial token sequence to text and re-encodes it , iteratively adjusting the token sequence length to match a target. This is necessary because some tokenizers do not guarantee a 1:1 mapping between consecutive tokens and the decoded-then-encoded sequence length. For example, for GPT2Tokenizer: [6880, 6881] -> ['Ġcalls', 'here'] -> [1650, 939, 486] -> ['Ġcall', 'sh', 'ere']
Returns a tuple of the final prompt string, the adjusted token sequence, and the token mismatch (final_len - target_token_len) if the retry budget is exhausted.
is_valid_sequence(prompt_len, output_len, min_len=4, max_prompt_len=1024, max_total_len=2048, skip_min_output_len_check=False)
¶
Validate a sequence based on prompt and output lengths.
Default pruning criteria are copied from the original sample_hf_requests
and sample_sharegpt_requests functions in benchmark_serving.py, as well as
from sample_requests in benchmark_throughput.py.
process_audio(audio)
¶
Process a single audio input and return a (array, sample_rate) tuple.
Supports: 1. String: treated as a file path, loaded with soundfile. 2. Dict with 'array' and 'sampling_rate' keys: HuggingFace audio format. 3. Tuple (array, sr): passed through directly.
process_image(image, *, ensure_client_side_data=False)
¶
Process a single image input and return a multimedia content dictionary.
Supports the following input types:
-
Dictionary with raw image bytes: - Expects a dict with a 'bytes' key containing raw image data. - Loads the bytes as a PIL.Image.Image.
-
PIL.Image.Image input: - Converts the image to RGB. - Saves the image as a JPEG in memory. - Encodes the JPEG data as a base64 string. - Returns a dictionary with the image as a base64 data URL.
-
String input: - Treats the string as a URL, local file path, or base64 encoded data. - If string starts with "data:image/", treats as base64.
- If string starts with "http://", "https://", or "file://", treats as URL.
- Otherwise treats as local file path and prepends "file://".
- If ensure_client_side_data is True, local and HTTP(S) image references are loaded and encoded as base64 image data URLs. Existing data:image URLs are kept unchanged.
- Returns a dictionary with the image URL or base64 data.
Raises:
-
ValueError–If the input is not a supported type.
process_video(video)
¶
Process a single video input and return a multimedia content dictionary.
Supports the following input types:
-
Dictionary with raw video bytes: - Expects a dict with a 'bytes' key containing raw video data.
-
String input: - Treats the string as a URL or local file path. - Prepends "file://" if the string doesn't start with "http://" or "file://". - Returns a dictionary with the image URL.
Raises:
-
ValueError–If the input is not a supported type.