Skip to content

[Feature] Support ThinkingBudget Logits processor to control thinking content length#6367

Open
jackyYang6 wants to merge 4 commits intoPaddlePaddle:developfrom
jackyYang6:feat/thinking-budget
Open

[Feature] Support ThinkingBudget Logits processor to control thinking content length#6367
jackyYang6 wants to merge 4 commits intoPaddlePaddle:developfrom
jackyYang6:feat/thinking-budget

Conversation

@jackyYang6
Copy link
Contributor

Motivation

引入 ThinkingBudget logits processor 用于限制 段长度,同时补充中英文使用文档与单测。

Modifications

  • 新增 ThinkingBudgetLogitsProcessor 并注册为内置 logits processor,用于控制思考长度。
  • DataProcessor 阶段进行 <think> prompt 状态预计算,避免首步 GPU 扫描 prompt。
  • 打通 Engine/SamplingParams 的参数透传链路。
  • 新增 thinking budget 行为单测。
  • 新增中英文功能文档并更新 mkdocs 导航。

Usage or Command

启动服务:

python -m fastdeploy.entrypoints.openai.api_server \
  --model Qwen/Qwen3-0.6B \
  --port 8180 \
  --metrics-port 8181 \
  --engine-worker-queue-port 8182 \
  --max-model-len 32768 \
  --max-num-seqs 32 \
  --logits-processors ThinkingBudgetLogitsProcessor

请求示例:

curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "你好!"}],
    "max_completion_tokens": 30,
    "logits_processors_args": {
      "thinking_budget": 20,
      "think_stop_sentence": "思考已达上限,开始回复"
    }
  }'

Accuracy Tests

不涉及 kernel 或模型 forward 逻辑变更,暂无精度回归需求。

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.

@paddle-bot
Copy link

paddle-bot bot commented Feb 5, 2026

Thanks for your contribution!

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 63.65591% with 169 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@72fe94c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/input/v1/text_processor.py 22.82% 67 Missing and 4 partials ⚠️
fastdeploy/input/text_processor.py 50.00% 35 Missing and 13 partials ⚠️
...model_executor/logits_processor/thinking_budget.py 84.61% 14 Missing and 22 partials ⚠️
fastdeploy/engine/common_engine.py 65.00% 2 Missing and 5 partials ⚠️
fastdeploy/engine/engine.py 65.00% 2 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6367   +/-   ##
==========================================
  Coverage           ?   67.64%           
==========================================
  Files              ?      392           
  Lines              ?    52628           
  Branches           ?     8240           
==========================================
  Hits               ?    35602           
  Misses             ?    14382           
  Partials           ?     2644           
Flag Coverage Δ
GPU 67.64% <63.65%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants