vllm.benchmarks.datasets ¶
Modules:
| Name | Description |
|---|---|
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. |
AIMODataset ¶
Bases: HuggingFaceDataset
Dataset class for processing a AIMO dataset with reasoning questions.
Source code in vllm/benchmarks/datasets/datasets.py
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 | | AMI | Meetings | Spontaneous | ihm, sdm | +----------------+----------------------------------------+--------------------------+-----------------------------+
Source code in vllm/benchmarks/datasets/datasets.py
3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 | |
BenchmarkDataset ¶
Bases: ABC
Source code in vllm/benchmarks/datasets/datasets.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
__init__ ¶
__init__(
dataset_path: str | None = None,
random_seed: int = DEFAULT_SEED,
disable_shuffle: bool = False,
**kwargs,
) -> None
Initialize the BenchmarkDataset with an optional dataset path and random seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_path | Optional[str] | Path to the dataset. If None, it indicates that a default or random dataset might be used. | None |
random_seed | int | Seed value for reproducible shuffling or sampling. Defaults to DEFAULT_SEED. | DEFAULT_SEED |
Source code in vllm/benchmarks/datasets/datasets.py
apply_multimodal_chat_transformation ¶
apply_multimodal_chat_transformation(
prompt: str,
mm_content: MultiModalDataDict
| dict
| list[dict]
| None = None,
) -> list[dict]
Transform a prompt and optional multimodal content into a chat format. This method is used for chat models that expect a specific conversation format.
Source code in vllm/benchmarks/datasets/datasets.py
get_lora_request ¶
get_lora_request(
index: int,
max_loras: int | None = None,
lora_path: str | None = None,
lora_assignment: str = "random",
) -> LoRARequest | None
Select a LoRA request using the specified assignment strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index | int | The request index (used for round-robin). | required |
max_loras | Optional[int] | The maximum number of LoRAs available. | None |
lora_path | Optional[str] | Path to the LoRA parameters on disk. | None |
lora_assignment | str | Strategy for LoRA selection. 'random' (default) or 'round-robin'. | 'random' |
Returns:
| Type | Description |
|---|---|
LoRARequest | None | A new |
LoRARequest | None | (or |
Source code in vllm/benchmarks/datasets/datasets.py
get_random_lora_request ¶
get_random_lora_request(
max_loras: int | None = None,
lora_path: str | None = None,
) -> LoRARequest | None
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:
| Name | Type | Description | Default |
|---|---|---|---|
max_loras | Optional[int] | The maximum number of LoRAs available. If | None |
lora_path | Optional[str] | Path to the LoRA parameters on disk. If | None |
Returns:
| Type | Description |
|---|---|
LoRARequest | None | A new |
LoRARequest | None | (or |
Source code in vllm/benchmarks/datasets/datasets.py
get_round_robin_lora_request ¶
get_round_robin_lora_request(
index: int,
max_loras: int | None = None,
lora_path: str | None = None,
) -> LoRARequest | None
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:
| Name | Type | Description | Default |
|---|---|---|---|
index | int | The request index used for round-robin selection. | required |
max_loras | Optional[int] | The maximum number of LoRAs available. If | None |
lora_path | Optional[str] | Path to the LoRA parameters on disk. If | None |
Returns:
| Type | Description |
|---|---|
LoRARequest | None | A new |
LoRARequest | None | (or |
Source code in vllm/benchmarks/datasets/datasets.py
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:
| Type | Description |
|---|---|
NotImplementedError | If a subclass does not implement this method. |
Source code in vllm/benchmarks/datasets/datasets.py
maybe_oversample_requests ¶
maybe_oversample_requests(
requests: list[SampleRequest],
num_requests: int,
request_id_prefix: str = "",
no_oversample: bool = False,
) -> None
Oversamples the list of requests if its size is less than the desired number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests | List[SampleRequest] | The current list of sampled requests. | required |
num_requests | int | The target number of requests. | required |
request_id_prefix | str | The prefix applied to generated request identifiers. | '' |
Source code in vllm/benchmarks/datasets/datasets.py
sample abstractmethod ¶
sample(
tokenizer: TokenizerLike,
num_requests: int,
request_id_prefix: str = "",
no_oversample: bool = False,
**kwargs,
) -> list[SampleRequest]
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:
| Name | Type | Description | Default |
|---|---|---|---|
tokenizer | TokenizerLike | The tokenizer to be used for processing the dataset's text. | required |
num_requests | int | The number of sample requests to generate. | required |
request_id_prefix | str | The prefix of request_id. | '' |
Returns:
| Type | Description |
|---|---|
list[SampleRequest] | list[SampleRequest]: A list of sample requests generated from the |
list[SampleRequest] | dataset. |
Source code in vllm/benchmarks/datasets/datasets.py
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
Source code in vllm/benchmarks/datasets/datasets.py
3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 | |
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.
Source code in vllm/benchmarks/datasets/datasets.py
3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 | |
ConversationDataset ¶
Bases: HuggingFaceDataset
Dataset for text-only conversation data.
Source code in vllm/benchmarks/datasets/datasets.py
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
Source code in vllm/benchmarks/datasets/datasets.py
2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 | |
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}
Source code in vllm/benchmarks/datasets/datasets.py
2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 | |
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.
Source code in vllm/benchmarks/datasets/datasets.py
2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | |
HuggingFaceDataset ¶
Bases: BenchmarkDataset
Base class for datasets hosted on HuggingFace.
Source code in vllm/benchmarks/datasets/datasets.py
load_data ¶
Load data from HuggingFace datasets.
Source code in vllm/benchmarks/datasets/datasets.py
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.
Source code in vllm/benchmarks/datasets/datasets.py
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.
Source code in vllm/benchmarks/datasets/datasets.py
4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 | |
MMStarDataset ¶
Bases: HuggingFaceDataset
Lin-Chen/MMStar: https://huggingface.co/datasets/Lin-Chen/MMStar refer to: https://github.com/sgl-project/SpecForge/pull/106
Source code in vllm/benchmarks/datasets/datasets.py
4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 | |
MMVUDataset ¶
Bases: HuggingFaceDataset
MMVU Dataset. https://huggingface.co/datasets/yale-nlp/MMVU
Source code in vllm/benchmarks/datasets/datasets.py
3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 | |
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
Source code in vllm/benchmarks/datasets/datasets.py
MultiModalConversationDataset ¶
Bases: HuggingFaceDataset
Dataset for multimodal conversation data.
Source code in vllm/benchmarks/datasets/datasets.py
NextEditPredictionDataset ¶
Bases: HuggingFaceDataset
Dataset class for processing a Next Edit Prediction dataset.
Source code in vllm/benchmarks/datasets/datasets.py
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.
Source code in vllm/benchmarks/datasets/datasets.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | |
generate_token_sequence ¶
generate_token_sequence(
*,
tokenizer: TokenizerLike,
prefix_token_ids: list[int],
prefix_len: int,
vocab_size: int,
input_len: int,
offset: int,
index: int,
allowed_tokens: ndarray,
) -> tuple[str, int, int]
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.
Source code in vllm/benchmarks/datasets/datasets.py
get_prefix ¶
Get the prefix for the dataset.
Source code in vllm/benchmarks/datasets/datasets.py
RandomDatasetForReranking ¶
Bases: RandomDataset
Random dataset specialized for the needs of scoring: - Batches of inputs - Inputs composed of pairs
Source code in vllm/benchmarks/datasets/datasets.py
771 772 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 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 | |
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.
Source code in vllm/benchmarks/datasets/datasets.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 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 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 | |
generate_mm_item ¶
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
Source code in vllm/benchmarks/datasets/datasets.py
generate_synthetic_image ¶
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.
Source code in vllm/benchmarks/datasets/datasets.py
generate_synthetic_video ¶
Generate synthetic video with random values.
Creates a video with random pixel values, encodes it to MP4 format, and returns the content as bytes.
Source code in vllm/benchmarks/datasets/datasets.py
get_mm_item_iterator ¶
get_mm_item_iterator(
min_num_mm_items: int,
max_num_mm_items: int,
bucket_config: dict[tuple[int, int, int], float],
limit_mm_per_prompt: dict[str, int],
) -> Iterator[tuple[int, int, int]]
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.
Source code in vllm/benchmarks/datasets/datasets.py
get_mm_item_sampling_params ¶
get_mm_item_sampling_params(
base_items_per_request: int,
num_mm_items_range_ratio: float,
limit_mm_per_prompt: dict[str, int],
bucket_config: dict[tuple[int, int, int], float],
) -> tuple[
int,
int,
dict[str, int],
dict[tuple[int, int, int], float],
]
Get the sampling parameters for the multimodal items.
Source code in vllm/benchmarks/datasets/datasets.py
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | |
map_config_to_modality ¶
Map the configuration to the modality.
Source code in vllm/benchmarks/datasets/datasets.py
normalize_bucket_config ¶
normalize_bucket_config(
bucket_config: dict[tuple[int, int, int], float],
) -> dict[tuple[int, int, int], float]
Remove zero probability entries and normalize the bucket config to sum to 1.
Source code in vllm/benchmarks/datasets/datasets.py
SampleRequest dataclass ¶
Represents a single inference request for benchmarking.
Source code in vllm/benchmarks/datasets/datasets.py
ShareGPTDataset ¶
Bases: BenchmarkDataset
Implements the ShareGPT dataset. Loads data from a JSON file and generates sample requests based on conversation turns.
Source code in vllm/benchmarks/datasets/datasets.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 | |
SonnetDataset ¶
Bases: BenchmarkDataset
Simplified implementation of the Sonnet dataset. Loads poem lines from a text file and generates sample requests. Default values here copied from benchmark_serving.py for the sonnet dataset.
Source code in vllm/benchmarks/datasets/datasets.py
3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 | |
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
Source code in vllm/benchmarks/datasets/datasets.py
VisionArenaDataset ¶
Bases: HuggingFaceDataset
Vision Arena Dataset.
Source code in vllm/benchmarks/datasets/datasets.py
add_random_dataset_base_args ¶
add_random_dataset_base_args(
parser_or_group: FlexibleArgumentParser
| _ArgumentGroup,
) -> None
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:
| Name | Type | Description | Default |
|---|---|---|---|
parser_or_group | FlexibleArgumentParser | _ArgumentGroup | Either a parser or an argument group to add arguments to. | required |
Source code in vllm/benchmarks/datasets/datasets.py
1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | |
add_random_multimodal_dataset_args ¶
add_random_multimodal_dataset_args(
parser_or_group: FlexibleArgumentParser
| _ArgumentGroup,
) -> None
Add CLI arguments for random multimodal dataset options.
This function adds arguments needed for: - random-mm (random multimodal dataset)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parser_or_group | FlexibleArgumentParser | _ArgumentGroup | Either a parser or an argument group to add arguments to. | required |
Source code in vllm/benchmarks/datasets/datasets.py
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 | |
gen_prompt_decode_to_target_len ¶
gen_prompt_decode_to_target_len(
tokenizer: TokenizerLike,
token_sequence: list[int],
target_token_len: int,
max_retry: int = 10,
add_special_tokens: bool = False,
rng: Generator | None = None,
) -> tuple[str, list[int], int]
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.
Source code in vllm/benchmarks/datasets/datasets.py
is_valid_sequence ¶
is_valid_sequence(
prompt_len: int,
output_len: int,
min_len: int = 4,
max_prompt_len: int = 1024,
max_total_len: int = 2048,
skip_min_output_len_check: bool = False,
) -> bool
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.
Source code in vllm/benchmarks/datasets/datasets.py
process_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.
Source code in vllm/benchmarks/datasets/datasets.py
process_image ¶
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:
| Type | Description |
|---|---|
ValueError | If the input is not a supported type. |
Source code in vllm/benchmarks/datasets/datasets.py
process_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:
| Type | Description |
|---|---|
ValueError | If the input is not a supported type. |