Skip to content

Commit 79f823c

Browse files
author
niushengxiao
committed
fix bugs in static_benchmark.py
1 parent 4420fa8 commit 79f823c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

test/benchmark/static_inference/static_benchmark.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,9 @@ def run_worker(args_dict: Dict, case_dicts: List[Dict], rank_id: int, ans_queue)
12561256
group_size = 2 if (args.enable_decode_microbatch_overlap or args.enable_prefill_microbatch_overlap) else 1
12571257
if group_size == 2:
12581258
for case in cases:
1259-
assert case.batch_size % 2 == 0, "microbatch overlap requires even batch_size"
1259+
assert case.batch_size == 1 or case.batch_size % 2 == 0, (
1260+
"microbatch overlap requires batch_size=1 or an even batch_size"
1261+
)
12601262

12611263
init_distributed_env(model_kvargs)
12621264
dist_group_manager.create_groups(group_size=group_size)
@@ -1284,6 +1286,7 @@ def run_worker(args_dict: Dict, case_dicts: List[Dict], rank_id: int, ans_queue)
12841286
message = {"ok": True, "rank": rank_id, "results": results}
12851287
all_rank_messages = [None] * int(args.tp) if rank_id == 0 else None
12861288
dist.gather_object(message, all_rank_messages, dst=0)
1289+
dist.barrier()
12871290
if rank_id == 0:
12881291
message["all_rank_messages"] = all_rank_messages
12891292
ans_queue.put(message)
@@ -1466,9 +1469,20 @@ def run_benchmark(args: SimpleNamespace, cases: Sequence[BenchmarkCase]) -> List
14661469
messages = []
14671470
while len(messages) < len(workers):
14681471
try:
1469-
messages.append(ans_queue.get(timeout=5))
1472+
message = ans_queue.get(timeout=5)
1473+
messages.append(message)
1474+
if not message.get("ok"):
1475+
for proc in workers:
1476+
if proc.is_alive():
1477+
proc.terminate()
1478+
break
14701479
continue
14711480
except queue.Empty:
1481+
if any(proc.exitcode not in (None, 0) for proc in workers):
1482+
for proc in workers:
1483+
if proc.is_alive():
1484+
proc.terminate()
1485+
break
14721486
if all(not proc.is_alive() for proc in workers):
14731487
break
14741488

0 commit comments

Comments
 (0)