Skip to content

Commit 7162cd4

Browse files
authored
configurable delay (#1963)
CVS-164856
1 parent 302fd50 commit 7162cd4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tools/llm_bench/benchmark.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ def get_argprser():
8585
help='if the value is 1, output the maximum memory consumption in warm-up iterations. If the value is 2,'
8686
' output the maximum memory consumption in all iterations.',
8787
)
88+
parser.add_argument(
89+
"--memory_consumption_delay",
90+
default=0.5,
91+
required=False,
92+
type=float,
93+
help="delay for memory consumption check in seconds, smaller value will lead to more precised memory consumption, but may affects performance."
94+
"It is not recommended to run memory consumption and performance benchmarking in the same time"
95+
)
8896
parser.add_argument('-bs', '--batch_size', type=int, default=1, required=False, help='Batch size value')
8997
parser.add_argument('--num_beams', type=int, default=1, help='Number of beams in the decoding strategy, activates beam_search if greater than 1')
9098
parser.add_argument(
@@ -230,6 +238,7 @@ def main():
230238
f'{original_torch_thread_nums} to {torch.get_num_threads()}, avoid to use the CPU cores for OpenVINO inference.')
231239
log.info(out_str)
232240
if args.memory_consumption:
241+
mem_consumption.delay = args.memory_consumption_delay
233242
mem_consumption.start_collect_mem_consumption_thread()
234243
try:
235244
if model_args['use_case'] in ['text_gen', 'code_gen']:

tools/llm_bench/llm_bench_utils/memory_profile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self):
1818
self.g_max_shared_mem_consumption = -1
1919
self.g_event = Event()
2020
self.g_data_event = Event()
21+
self.delay = 0.5
2122

2223
def collect_memory_consumption(self):
2324
"""Collect the data."""
@@ -54,7 +55,7 @@ def collect_memory_consumption(self):
5455
self.g_event.clear()
5556
self.g_end_collect_mem = False
5657
break
57-
time.sleep(0.0001)
58+
time.sleep(self.delay)
5859

5960
def start_collect_memory_consumption(self):
6061
"""Start collect."""

0 commit comments

Comments
 (0)