Skip to content

Commit 75e4a6a

Browse files
Isotr0pyavigny
authored andcommitted
[Misc] Add packages for benchmark as extra dependency (vllm-project#19089)
Signed-off-by: Isotr0py <[email protected]> Signed-off-by: avigny <[email protected]>
1 parent d88b6d2 commit 75e4a6a

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

docs/cli/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ vllm complete --quick "The future of AI is"
7777

7878
Run benchmark tests for latency online serving throughput and offline inference throughput.
7979

80+
To use benchmark commands, please install with extra dependencies using `pip install vllm[bench]`.
81+
8082
Available Commands:
8183

8284
```bash

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ def _read_requirements(filename: str) -> list[str]:
688688
ext_modules=ext_modules,
689689
install_requires=get_requirements(),
690690
extras_require={
691+
"bench": ["pandas", "datasets"],
691692
"tensorizer": ["tensorizer>=2.9.0"],
692693
"fastsafetensors": ["fastsafetensors >= 0.1.10"],
693694
"runai": ["runai-model-streamer", "runai-model-streamer-s3", "boto3"],

vllm/benchmarks/datasets.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from typing import Any, Callable, Optional, Union
2525

2626
import numpy as np
27-
import pandas as pd
2827
from PIL import Image
2928
from transformers import PreTrainedTokenizerBase
3029

@@ -33,6 +32,23 @@
3332
from vllm.multimodal import MultiModalDataDict
3433
from vllm.multimodal.image import convert_image_mode
3534
from vllm.transformers_utils.tokenizer import AnyTokenizer, get_lora_tokenizer
35+
from vllm.utils import PlaceholderModule
36+
37+
try:
38+
from datasets import load_dataset
39+
except ImportError:
40+
datasets = PlaceholderModule("datasets")
41+
load_dataset = datasets.placeholder_attr("load_dataset")
42+
43+
try:
44+
import pandas as pd
45+
except ImportError:
46+
pd = PlaceholderModule("pandas")
47+
48+
try:
49+
import librosa
50+
except ImportError:
51+
librosa = PlaceholderModule("librosa")
3652

3753
logger = logging.getLogger(__name__)
3854

@@ -636,13 +652,6 @@ def load_data(self, ):
636652
if self.dataset_path is None:
637653
raise ValueError("dataset_path must be provided for loading data.")
638654

639-
try:
640-
import pandas as pd
641-
except ImportError as e:
642-
raise ImportError(
643-
"Pandas is required for BurstGPTDataset. Please install it "
644-
"using `pip install pandas`.") from e
645-
646655
df = pd.read_csv(self.dataset_path)
647656
# Filter to keep only GPT-4 rows.
648657
gpt4_df = df[df["Model"] == "GPT-4"]
@@ -717,13 +726,6 @@ def __init__(
717726

718727
def load_data(self) -> None:
719728
"""Load data from HuggingFace datasets."""
720-
try:
721-
from datasets import load_dataset
722-
except ImportError as e:
723-
raise ImportError(
724-
"Hugging Face datasets library is required for this dataset. "
725-
"Please install it using `pip install datasets`.") from e
726-
727729
self.data = load_dataset(
728730
self.dataset_path,
729731
name=self.dataset_subset,
@@ -1147,13 +1149,6 @@ def sample(
11471149
output_len: Optional[int] = None,
11481150
**kwargs,
11491151
) -> list:
1150-
try:
1151-
import librosa
1152-
except ImportError as e:
1153-
raise ImportError(
1154-
"librosa is required for ASRDataset. Please install it "
1155-
"using `pip install librosa`.") from e
1156-
11571152
output_len = (output_len
11581153
if output_len is not None else self.DEFAULT_OUTPUT_LEN)
11591154
prompt = ASRDataset.TRANSCRIPTION_PREAMBLE

0 commit comments

Comments
 (0)