执行摘要
支持 --model 作为 --model-path 的 CLI 别名
PR 标题和 commit message 明确指出:允许用户使用 --model 作为 --model-path 的别名,匹配其他流行 serving 框架的惯例,提升 CLI 易用性和用户迁移体验。
该 PR 改动简单直接,无需精读。可合并用于提升 CLI 用户体验。
PR 无 review 评论讨论。
PR 标题和 commit message 明确指出:允许用户使用 --model 作为 --model-path 的别名,匹配其他流行 serving 框架的惯例,提升 CLI 易用性和用户迁移体验。
该 PR 改动简单直接,无需精读。可合并用于提升 CLI 用户体验。
PR 无 review 评论讨论。
python/sglang/cli/utils.py 的 get_model_path 函数中(第106行),将 if arg == "--model-path" 改为 if arg in ("--model-path", "--model"),同时在第110行,将 elif arg.startswith("--model-path=") 扩展为 elif arg.startswith("--model-path=") or arg.startswith("--model="),从而支持等号赋值形式。| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
python/sglang/cli/utils.py |
CLI | modified | 4.24 |
python/sglang/cli/utils.py
core-logic
唯一被修改的文件,核心变更在 get_model_path 函数,支持 --model 作为 --model-path 的别名。
# python/sglang/cli/utils.py
def get_model_path(extra_argv):
# Find the model_path argument
model_path = None
for i, arg in enumerate(extra_argv):
# 支持 --model-path 和 --model 两种 flag
if arg in ("--model-path", "--model"):
if i + 1 < len(extra_argv):
model_path = extra_argv[i + 1]
break
# 同时支持等号赋值形式,如 --model=xxx 或 --model-path=xxx
elif arg.startswith("--model-path=") or arg.startswith("--model="):
model_path = arg.split("=", 1)[1]
break
if model_path is None:
if any(h in extra_argv for h in ["-h", "--help"]):
raise Exception(
"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\n"
"This command can launch either a standard language model server or a diffusion model server.\n"
"The server type is determined by the --model-path.\n"
)
else:
raise Exception(
"Error: --model-path is required. "
"Please provide the path to the model."
)
return model_path
当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。
风险极低。改动仅两行,在 CLI 参数解析中增加一个逻辑分支,不改变原有 --model-path 的行为,不会影响内部核心逻辑或性能。但需注意,若已有模型名称恰好以 --model= 开头(极不可能),可能产生误匹配。
影响范围极小。仅对使用 CLI 启动服务时通过 --model 参数传递模型路径的用户有正面影响;现有 --model-path 用户不受影响。无需考虑回滚或兼容性。
当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。
参与讨论