From f76c6c95bec2105ac4e9aed0992ecc7d3ad2c236 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Tue, 23 Jun 2026 18:39:58 -0700 Subject: [PATCH] [misc] Add sglang.bench_offline_throughput deprecation shim (#29085) --- python/sglang/bench_offline_throughput.py | 23 +++++++++++++++++++ python/sglang/bench_one_batch.py | 2 +- python/sglang/benchmark/offline_throughput.py | 8 +++++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 python/sglang/bench_offline_throughput.py diff --git a/python/sglang/bench_offline_throughput.py b/python/sglang/bench_offline_throughput.py new file mode 100644 index 000000000..ab501aea9 --- /dev/null +++ b/python/sglang/bench_offline_throughput.py @@ -0,0 +1,23 @@ +"""Deprecated import path for ``sglang.benchmark.offline_throughput``. + +``python -m sglang.bench_offline_throughput`` and +``from sglang.bench_offline_throughput import ...`` still work, but the +implementation now lives in ``sglang.benchmark.offline_throughput``. +Update references to the new path. +""" + +import warnings + +from sglang.benchmark.offline_throughput import * # noqa: F401,F403 +from sglang.benchmark.offline_throughput import cli_main + +warnings.warn( + "`sglang.bench_offline_throughput` is deprecated and will be removed in a " + "future release; use `sglang.benchmark.offline_throughput` instead " + "(e.g. `python -m sglang.benchmark.offline_throughput`).", + DeprecationWarning, + stacklevel=1, +) + +if __name__ == "__main__": + cli_main() diff --git a/python/sglang/bench_one_batch.py b/python/sglang/bench_one_batch.py index bd38d359e..bb2a64b87 100644 --- a/python/sglang/bench_one_batch.py +++ b/python/sglang/bench_one_batch.py @@ -15,7 +15,7 @@ warnings.warn( "release; use `sglang.benchmark.one_batch` instead " "(e.g. `python -m sglang.benchmark.one_batch`).", DeprecationWarning, - stacklevel=2, + stacklevel=1, ) if __name__ == "__main__": diff --git a/python/sglang/benchmark/offline_throughput.py b/python/sglang/benchmark/offline_throughput.py index db2f1441c..2002db6b4 100644 --- a/python/sglang/benchmark/offline_throughput.py +++ b/python/sglang/benchmark/offline_throughput.py @@ -418,7 +418,7 @@ def throughput_test( # Parse args extra_request_body = {} if bench_args.extra_request_body: - extra_request_body = json.loads(args.extra_request_body) + extra_request_body = json.loads(bench_args.extra_request_body) # Read dataset input_requests = get_dataset(bench_args, tokenizer) @@ -504,7 +504,7 @@ def throughput_test( return result -if __name__ == "__main__": +def cli_main(): parser = argparse.ArgumentParser() ServerArgs.add_cli_args(parser) BenchArgs.add_cli_args(parser) @@ -541,3 +541,7 @@ if __name__ == "__main__": while bench_args.do_not_exit: pass + + +if __name__ == "__main__": + cli_main()