Skip to content

Commit 910d791

Browse files
committed
fix: tolerate upstream sa-bench chat args
1 parent a32a5e1 commit 910d791

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

benchmarks/multi_node/force_srt_infinitebench.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from __future__ import annotations
1010

1111
import sys
12+
import re
1213
from pathlib import Path
1314

1415

@@ -504,17 +505,20 @@ def patch_bench_sh(path: Path) -> None:
504505
--num-chips "$TOTAL_GPUS" \\
505506
''',
506507
)
507-
warmup_without_chat = ''' --trust-remote-code \\
508-
"${CUSTOM_TOKENIZER_ARGS[@]}"
509-
510-
num_prompts='''
511-
warmup_with_chat = ''' --trust-remote-code \\
512-
"${CHAT_TEMPLATE_ARGS[@]}" \\
513-
"${CUSTOM_TOKENIZER_ARGS[@]}"
514-
515-
num_prompts='''
516-
if warmup_with_chat not in text:
517-
text = replace_once(text, warmup_without_chat, warmup_with_chat, path)
508+
trust_remote_code_without_chat = re.compile(
509+
r'(?m)^(?P<indent>\s*)--trust-remote-code \\\n'
510+
r'(?P=indent)"\$\{CUSTOM_TOKENIZER_ARGS\[@\]\}"'
511+
)
512+
text, replacements = trust_remote_code_without_chat.subn(
513+
r'\g<indent>--trust-remote-code \\' + "\n"
514+
r'\g<indent>"${CHAT_TEMPLATE_ARGS[@]}" \\' + "\n"
515+
r'\g<indent>"${CUSTOM_TOKENIZER_ARGS[@]}"',
516+
text,
517+
)
518+
if replacements == 0 and '"${CHAT_TEMPLATE_ARGS[@]}"' not in text:
519+
raise RuntimeError(
520+
f"Expected sa-bench trust-remote-code/custom-tokenizer block not found in {path}"
521+
)
518522

519523
path.write_text(text)
520524

0 commit comments

Comments
 (0)