Skip to content

[BugFix] fix multi-step mtp bug#6754

Merged
kevincheng2 merged 1 commit into
PaddlePaddle:developfrom
ddchenhao66:fix_multi_mtp
Mar 11, 2026
Merged

[BugFix] fix multi-step mtp bug#6754
kevincheng2 merged 1 commit into
PaddlePaddle:developfrom
ddchenhao66:fix_multi_mtp

Conversation

@ddchenhao66
Copy link
Copy Markdown
Collaborator

@ddchenhao66 ddchenhao66 commented Mar 10, 2026

Motivation

多步step需要的cache kv长度是超过原始prompt长度的,所以在分配block时需要多分配一个。

Modifications

删掉skip_allocate判断,即使cache完全命中,在mtp下也会多分配一个给当前req。

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.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Mar 10, 2026

Thanks for your contribution!

num_new_tokens = self._get_num_new_tokens(request, token_budget)
if num_new_tokens == 0:
num_new_block = self.get_new_block_nums(request, num_new_tokens)
if num_new_block == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

想了一下,这里num_new_block == 0 的场景也是要插入计算的。cache完全命中的场景已经有了足够的block,不需要再分配block,但还需要插入计算。可以还原回之前的num_new_tokens 判断

num_new_block, request.request_id
)
request.block_tables.extend(extra_gpu_block_ids)
extra_gpu_block_ids = self.cache_manager.allocate_gpu_blocks(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里可以把之前的 skip_allocate 判断改成 if num_new_block > 0 ?

# Allocate blocks for the tokens that does not hit cache
num_new_tokens = self._get_num_new_tokens(request, token_budget)
if num_new_tokens == 0:
num_new_block = self.get_new_block_nums(request, num_new_tokens)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

同上

num_new_block, request.request_id
)
request.block_tables.extend(extra_gpu_block_ids)
extra_gpu_block_ids = self.cache_manager.allocate_gpu_blocks(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

同上

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@30f9f33). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/sched/resource_manager_v1.py 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6754   +/-   ##
==========================================
  Coverage           ?   72.20%           
==========================================
  Files              ?      394           
  Lines              ?    54211           
  Branches           ?     8493           
==========================================
  Hits               ?    39145           
  Misses             ?    12267           
  Partials           ?     2799           
Flag Coverage Δ
GPU 72.20% <33.33%> (?)

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.

@kevincheng2 kevincheng2 merged commit a502dda into PaddlePaddle:develop Mar 11, 2026
21 of 24 checks passed
@ddchenhao66 ddchenhao66 deleted the fix_multi_mtp branch March 11, 2026 02:30
mattheliu pushed a commit to mattheliu/FastDeploy that referenced this pull request Apr 1, 2026
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
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