Skip to content

Commit 8f4afe0

Browse files
vlsavsumitd2
authored andcommitted
Update benchmark_serving.py to read and write json-datasets, results in UTF8, for better compatibility with Windows (vllm-project#8997)
Signed-off-by: Sumit Dubey <sumit.dubey2@ibm.com>
1 parent 17f32c3 commit 8f4afe0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

benchmarks/benchmark_serving.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def sample_sharegpt_requests(
9090
fixed_output_len: Optional[int] = None,
9191
) -> List[Tuple[str, int, int, None]]:
9292
# Load the dataset.
93-
with open(dataset_path) as f:
93+
with open(dataset_path, encoding='utf-8') as f:
9494
dataset = json.load(f)
9595
# Filter out the conversations with less than 2 turns.
9696
dataset = [data for data in dataset if len(data["conversations"]) >= 2]
@@ -139,7 +139,7 @@ def sample_sonnet_requests(
139139
), "'args.sonnet-input-len' must be greater than 'args.prefix-input-len'."
140140

141141
# Load the dataset.
142-
with open(dataset_path) as f:
142+
with open(dataset_path, encoding='utf-8') as f:
143143
poem_lines = f.readlines()
144144

145145
# Tokenize the poem lines.
@@ -726,7 +726,7 @@ def main(args: argparse.Namespace):
726726
file_name = args.result_filename
727727
if args.result_dir:
728728
file_name = os.path.join(args.result_dir, file_name)
729-
with open(file_name, "w") as outfile:
729+
with open(file_name, "w", encoding='utf-8') as outfile:
730730
json.dump(result_json, outfile)
731731

732732

0 commit comments

Comments
 (0)