Skip to content

Commit 0491343

Browse files
Feature/modelscope model download (#8083)
Co-authored-by: ronnie_zheng <[email protected]>
1 parent 0ad098b commit 0491343

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

python/sglang/bench_offline_throughput.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,26 @@ def throughput_test(
418418
ServerArgs.add_cli_args(parser)
419419
BenchArgs.add_cli_args(parser)
420420
args = parser.parse_args()
421+
422+
# handling ModelScope model downloads
423+
if os.getenv("SGLANG_USE_MODELSCOPE", "false").lower() in ("true", "1"):
424+
if os.path.exists(args.model_path):
425+
print(f"Using local model path: {args.model_path}")
426+
else:
427+
try:
428+
from modelscope import snapshot_download
429+
430+
print(f"Using ModelScope to download model: {args.model_path}")
431+
432+
# download the model and replace args.model_path
433+
args.model_path = snapshot_download(
434+
args.model_path,
435+
)
436+
print(f"Model downloaded to: {args.model_path}")
437+
except Exception as e:
438+
print(f"ModelScope download failed: {str(e)}")
439+
raise e
440+
421441
server_args = ServerArgs.from_cli_args(args)
422442
bench_args = BenchArgs.from_cli_args(args)
423443

0 commit comments

Comments
 (0)