Skip to content

[BugFix] Fix potential Python type error in exception tests.#7945

Open
flsgavin wants to merge 1 commit into
PaddlePaddle:release/online/20260415from
flsgavin:release/online/20260415
Open

[BugFix] Fix potential Python type error in exception tests.#7945
flsgavin wants to merge 1 commit into
PaddlePaddle:release/online/20260415from
flsgavin:release/online/20260415

Conversation

@flsgavin
Copy link
Copy Markdown

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

在异常测试中,包含input_ids = "1,2,3,4,5" 这样的异常字符串caae,FastDeploy 的 insert_tasks_v1 方法缺少对 input_ids / prompt_token_ids 的输入类型校验。当上游传入非法类型的数据时(例如string类型),服务直接 crash 。

image

Modifications

在input_ids = prompt_token_ids + request.output_token_ids前面增加prompt_token_ids的参数类型校验,如果类型异常直接终止这条请求。

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 27, 2026

CLA assistant check
All committers have signed the CLA.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 27, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label May 27, 2026
Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-05-27 20:30:53

📋 Review 摘要

PR 概述:在 insert_tasks_v1 方法中增加 prompt_token_ids 类型校验,防止非法类型输入导致服务 crash。
变更范围fastdeploy/worker/gpu_model_runner.py
影响面 Tag[BugFix] [Engine]

问题

级别 文件 概述
🟡 建议 gpu_model_runner.py:878 类型校验未同步到其他硬件 ModelRunner

📝 PR 规范检查

存在以下问题:

  1. PR 目标分支为 release/online/20260415(非 develop),标题应使用 Cherry-Pick 格式并附原 PR 号;
  2. 标题中 "in exception tests" 描述不准确,修改发生在生产代码而非测试文件;
  3. Usage or CommandAccuracy Tests 段落为空,应填写 N/A
  4. Checklist 未按实际情况勾选。

标题建议(可直接复制):

  • [Cherry-Pick][BugFix] Fix prompt_token_ids type validation in insert_tasks_v1 (#原PR号)
PR 描述建议(点击展开,可直接复制)
## Motivation
在异常测试中,当上游传入非法类型的数据(如 string 类型的 input_ids)时,`insert_tasks_v1` 方法缺少对 `prompt_token_ids` 的输入类型校验,导致服务直接 crash。

## Modifications`fastdeploy/worker/gpu_model_runner.py``insert_tasks_v1` 方法中,在 `input_ids = prompt_token_ids + request.output_token_ids` 之前增加 `prompt_token_ids` 的参数类型校验:若类型不是 `list``np.ndarray`,则记录错误日志并通过设置 `stop_flags``seq_lens_this_time_buffer``seq_lens_encoder` 终止该请求。

## Usage or Command
N/A

## Accuracy Tests
N/A

## Checklist

- [x] Add at least a tag in the PR title.
  - Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
  - You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [ ] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.

总体评价

修复思路正确,有效防止了非法类型输入导致的 crash。建议同步到其他硬件 ModelRunner,并补充 Cherry-Pick 格式标题及完整 PR 描述。

self.share_inputs["max_reply_lens"][idx : idx + 1, :] = -1
self.share_inputs["limit_think_status"][idx : idx + 1, :] = 0

if not isinstance(request.prompt_token_ids, (list, np.ndarray)):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 此类型校验仅在 gpu_model_runner.py 中添加,其他硬件 ModelRunner(xpu_model_runner.pydcu_model_runner.pygcu_model_runner.pyhpu_model_runner.pyiluvatar_model_runner.pymetax_model_runner.py)中的 insert_tasks_v1 方法若存在相同逻辑,也应同步添加此校验,否则其他硬件上仍会 crash。

建议修复方式:
检查上述各硬件 ModelRunner 的 insert_tasks_v1 方法,在相同位置添加等价的类型校验逻辑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants