From 04913430c66986f4e78d7e2c61bee970831587a3 Mon Sep 17 00:00:00 2001 From: yrk111222 <2493404415@qq.com> Date: Fri, 1 Aug 2025 08:29:31 +0800 Subject: [PATCH] Feature/modelscope model download (#8083) Co-authored-by: ronnie_zheng --- python/sglang/bench_offline_throughput.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/python/sglang/bench_offline_throughput.py b/python/sglang/bench_offline_throughput.py index 1ae893d46..457d120d9 100644 --- a/python/sglang/bench_offline_throughput.py +++ b/python/sglang/bench_offline_throughput.py @@ -418,6 +418,26 @@ if __name__ == "__main__": ServerArgs.add_cli_args(parser) BenchArgs.add_cli_args(parser) args = parser.parse_args() + + # handling ModelScope model downloads + if os.getenv("SGLANG_USE_MODELSCOPE", "false").lower() in ("true", "1"): + if os.path.exists(args.model_path): + print(f"Using local model path: {args.model_path}") + else: + try: + from modelscope import snapshot_download + + print(f"Using ModelScope to download model: {args.model_path}") + + # download the model and replace args.model_path + args.model_path = snapshot_download( + args.model_path, + ) + print(f"Model downloaded to: {args.model_path}") + except Exception as e: + print(f"ModelScope download failed: {str(e)}") + raise e + server_args = ServerArgs.from_cli_args(args) bench_args = BenchArgs.from_cli_args(args)