1919
2020import argparse
2121import array
22- import json
2322import logging
2423import random
24+ import threading
2525
2626logging .basicConfig (level = logging .INFO )
2727import math
5353 SUPPORTED_DATASETS ,
5454)
5555
56-
5756logger : logging .Logger = logging .getLogger ("main" )
5857
5958torch .multiprocessing .set_start_method ("spawn" , force = True )
@@ -99,16 +98,16 @@ def get_args(): # pyre-ignore [3]
9998 "--find-peak-performance" , default = False , help = "Whether to find peak performance in the benchmark"
10099 )
101100 parser .add_argument (
102- "--dataset-path-prefix" , default = " " , help = "Prefix to the dataset path. Example: /home/username/"
101+ "--dataset-path-prefix" , default = f"/home/ { os . getlogin () } / " , help = "Prefix to the dataset path. Example: /home/username/"
103102 )
104103 parser .add_argument (
105- "--warmup-ratio" , default = 0.1 , help = "The ratio of the dataset used to warmup SUT"
104+ "--warmup-ratio" , default = 0.3 , help = "The ratio of the dataset used to warmup SUT"
106105 )
107106 parser .add_argument (
108107 "--num-queries" , default = 500000 , help = "Number of queries to run in the benchmark"
109108 )
110109 parser .add_argument (
111- "--target-qps" , default = 1500 , help = "Benchmark target QPS. Needs to be tuned for different implementations to balance latency and throughput"
110+ "--target-qps" , default = 1000 , help = "Benchmark target QPS. Needs to be tuned for different implementations to balance latency and throughput"
112111 )
113112 parser .add_argument (
114113 "--numpy-rand-seed" , default = 123 , help = "Numpy random seed"
@@ -332,6 +331,7 @@ def __init__(
332331 get_num_queries (input_queries , self .total_requests ) // self .total_requests
333332 )
334333 self .repeat : int = 0
334+ self ._lock = threading .Lock ()
335335
336336 def get_num_requests (self , warmup_ratio : float ) -> List [int ]:
337337 return [
@@ -359,6 +359,7 @@ def init_sut(self) -> None:
359359 self .ts = self .start_ts
360360 self .ds .set_ts (self .start_ts )
361361 self .cnt = 0
362+ self .repeat = 0
362363
363364 def load_query_samples (self , query_ids : List [Optional [int ]]) -> None :
364365 length = len (query_ids )
@@ -382,25 +383,27 @@ def unload_query_samples(self, sample_list: List[int]) -> None:
382383 def get_samples (self , id_list : List [int ]) -> Samples :
383384 batch_size : int = len (id_list )
384385 ts_idx : int = 0
385- while self .num_requests_cumsum [ts_idx ] <= self .cnt :
386- ts_idx += 1
387- offset : int = 0 if ts_idx == 0 else self .num_requests_cumsum [ts_idx - 1 ]
386+ with self ._lock :
387+ current_cnt : int = self .cnt
388+ while self .num_requests_cumsum [ts_idx ] <= current_cnt :
389+ ts_idx += 1
390+ offset : int = 0 if ts_idx == 0 else self .num_requests_cumsum [ts_idx - 1 ]
391+ self .repeat += 1
392+ if self .repeat == self .num_repeats :
393+ self .repeat = 0
394+ self .cnt += batch_size
388395 output : Samples = self .ds .get_samples_with_ts (
389- self .run_order [ts_idx ][self . cnt - offset : self . cnt + batch_size - offset ],
396+ self .run_order [ts_idx ][current_cnt - offset : current_cnt + batch_size - offset ],
390397 ts_idx + self .start_ts ,
391398 )
392- self .repeat += 1
393- if self .repeat == self .num_repeats :
394- self .repeat = 0
395- self .cnt += batch_size
396399 return output
397400
398401 def get_item_count (self ) -> int :
399402 return self .total_requests
400403
401404
402405def run (
403- dataset : str = "debug " ,
406+ dataset : str = "sampled-streaming-100b " ,
404407 model_path : str = "" ,
405408 scenario_name : str = "Server" ,
406409 batchsize : int = 16 ,
0 commit comments