Skip to content

Commit

Permalink
[Bugfix] Add random_seed to sample_hf_requests in benchmark_serving s…
Browse files Browse the repository at this point in the history
…cript (#9013)

Co-authored-by: Isotr0py <2037008807@qq.com>
  • Loading branch information
wukaixingxp and Isotr0py authored Oct 17, 2024
1 parent eca2c5f commit d65049d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions benchmarks/benchmark_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def sample_hf_requests(
dataset_split: str,
num_requests: int,
tokenizer: PreTrainedTokenizerBase,
random_seed: int,
fixed_output_len: Optional[int] = None,
) -> List[Tuple[str, str, int, Optional[Dict[str, Collection[str]]]]]:
dataset = load_dataset(dataset_path,
Expand All @@ -210,8 +211,8 @@ def sample_hf_requests(
streaming=True)
assert "conversations" in dataset.features, (
"HF Dataset must have 'conversations' column.")
filtered_dataset = dataset.shuffle().filter(
lambda x: len(x["conversations"]) >= 2)
filter_func = lambda x: len(x["conversations"]) >= 2
filtered_dataset = dataset.shuffle(seed=random_seed).filter(filter_func)
sampled_requests: List[Tuple[str, int, int, Dict[str,
Collection[str]]]] = []
for data in filtered_dataset:
Expand Down Expand Up @@ -646,6 +647,7 @@ def main(args: argparse.Namespace):
dataset_split=args.hf_split,
num_requests=args.num_prompts,
tokenizer=tokenizer,
random_seed=args.seed,
fixed_output_len=args.hf_output_len,
)

Expand Down

0 comments on commit d65049d

Please sign in to comment.