From 7e629a2f8cc5f491ca5e25aab8cc69c8dcf1875e Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Mon, 15 Jun 2026 13:07:50 -0700 Subject: [PATCH] Allow overriding tokenizer path in benchmark harness (#28280) Co-authored-by: Ian O'Connell --- .../test/bench_one_batch_server_internal.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python/sglang/test/bench_one_batch_server_internal.py b/python/sglang/test/bench_one_batch_server_internal.py index 90b8a1f51..45b3947ec 100644 --- a/python/sglang/test/bench_one_batch_server_internal.py +++ b/python/sglang/test/bench_one_batch_server_internal.py @@ -95,6 +95,7 @@ class BenchArgs: client_stream_interval: int = 1 input_len_step_percentage: float = 0.0 base_url: str = "" + local_tokenizer_path: str = "" skip_warmup: bool = False show_report: bool = False profile: bool = False @@ -149,6 +150,16 @@ class BenchArgs: default=BenchArgs.input_len_step_percentage, ) parser.add_argument("--base-url", type=str, default=BenchArgs.base_url) + parser.add_argument( + "--local-tokenizer-path", + type=str, + default=BenchArgs.local_tokenizer_path, + help=( + "Local tokenizer path to use when benchmarking an external " + "SGLang server via --base-url. Defaults to the tokenizer path " + "reported by /server_info." + ), + ) parser.add_argument("--skip-warmup", action="store_true") parser.add_argument("--show-report", action="store_true") parser.add_argument("--profile", action="store_true") @@ -905,7 +916,9 @@ def run_benchmark_internal( response = requests.get(base_url + "/server_info", timeout=DEFAULT_TIMEOUT) response.raise_for_status() server_info = response.json() - if "tokenizer_path" in server_info: + if bench_args.local_tokenizer_path: + tokenizer_path = bench_args.local_tokenizer_path + elif "tokenizer_path" in server_info: tokenizer_path = server_info["tokenizer_path"] elif "prefill" in server_info: tokenizer_path = server_info["prefill"][0]["tokenizer_path"]