已合并
[Bugfix] 修复多模态tokenizer特殊token拆分逻辑,避免恶意token导致服务异常 #928
[Bugfix] 修复多模态tokenizer特殊token拆分逻辑,避免恶意token导致服务异常 #928
已合并
muziyuhui666创建于 4月21日
muziyuhui666
4月21日

合入背景

针对多模态模型服务化场景,发现 /v1/completions 接口在输入恶意多模态特殊token时存在稳定性风险,可能导致推理服务异常退出(DoS现象)。
本PR用于修正多模态/纯文本模型在 tokenizer 特殊token拆分行为上的判定来源,避免通过不稳定路径触发子进程崩溃。
Fix part of #536

修改内容

  1. BaseRouter 中新增统一能力标识 is_multimodal(默认 False)。
  2. 在多模态模型对应 router 中显式声明 is_multimodal=True(如 qwen2_vl、qwen3_vl、internvl、llava、llava_next、vita、glm4v、glm41v、qwen2_audio、minicpm_qwen2_v2、mllama、internlmxcomposer2、janus、yivl 等)。
  3. TokenizerWrapper 中读取 router_ins.is_multimodal,并据此设置 split_special_tokens,统一多模态与纯文本模型行为。
  4. 回避了此前基于 model_cls/load_atb_speed() 的不稳定路径,避免 tokenizer worker 初始化阶段出现崩溃风险。
  5. 对本次改动涉及文件执行了 pre-commit,并提交自动修复结果。

资料变更

不涉及。

接口变更

不涉及跨代码仓或客户面可见接口变更。
本PR仅调整内部路由能力标记与 tokenizer 参数传递逻辑,对外REST/gRPC接口字段无新增、无删减、无语义变更。

测试结果

  1. 服务拉起测试

    • 场景:qwen2.5-vl 服务化启动(多次重复)
    • 结果:服务可稳定拉起,未再出现 tokenizer 子进程 Segmentation fault/Aborted。
  2. 恶意请求稳定性测试

    • 场景:/v1/completions 注入恶意多模态特殊token请求
    • 结果:服务端未挂起,请求端可收到响应,未复现服务进程退出。
  3. 正常功能回归测试

    • 场景:正常 chat/completions 多模态请求、正常文本请求
    • 结果:结果可正常返回,功能行为符合预期。
  4. 静态门禁测试

    • 场景:对本PR修改文件执行 pre-commit
    • 方法:pre-commit run --files <changed files>
    • 结果:通过(含自动格式修复后再次通过)。

CheckList

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 muziyuhui666 的贡献)
ascend-robotascend-robot成员
4月21日 添加了label:stat/needs-squash
ascend-robot
ascend-robot成员
4月21日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/MindIE-LLM 陈歆怡, xsxhw1 (2/2) 陈歆怡 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

muziyuhui666, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
4月21日 添加了label:ascend-cla/yes
ascend-robotascend-robot成员
4月21日 添加了label:needs-issue
ascend-robot
ascend-robot成员
4月21日 评论:

Linking Issue Notice

@muziyuhui666 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

likedislike
此处折叠了142条消息 查看更多
ascend-robotascend-robot成员
4月23日 删除了label:ci-pipeline-passed
ascend-robotascend-robot成员
4月23日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
4月24日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
4月24日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
4月24日 评论:
阶段 任务名 状态 详情
编译构建 Build_ops_x86_A3 >>>
Build_ops_arm_A3 >>>
Build_ops_x86_A2 >>>
Build_ops_arm_A2 >>>
Build_linux_x86_abi1_atb >>>
Build_linux_x86_abi1_llm >>>
Build_linux_arm_abi1_atb >>>
Build_linux_arm_abi1_llm >>>
Build_linux_arm_abi0_atb >>>
Build_linux_arm_abi0_llm >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 pre-commit >>>
开源片段检查 SCA >>>
开发者测试 UT_linux_arm_mindie-llm >>>
UT_linux_arm_atb-models >>>
流水线 PR-pipeline_MindIE-LLM_gitcode >>>
likedislike