Skip to content

Conversation

@rainyfly
Copy link
Collaborator

Motivation

Enable prefix caching for mtp by default.

Modifications

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.

Copilot AI review requested due to automatic review settings November 30, 2025 08:21
@paddle-bot
Copy link

paddle-bot bot commented Nov 30, 2025

Thanks for your contribution!

Copilot finished reviewing on behalf of rainyfly November 30, 2025 08:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables prefix caching for Multi-Token Prediction (MTP) speculative decoding by removing a conditional check that previously disabled this feature when speculative_config was present.

Key Changes

  • Removes the check that disabled enable_prefix_caching when speculative_config is not None
  • Allows MTP to benefit from prefix caching, which should improve performance for requests with shared prefixes
  • The MTP implementation code already supports prefix caching (as seen in fastdeploy/spec_decode/mtp.py line 180)

Comment on lines 487 to 490
if self.splitwise_role == "decode":
self.enable_prefix_caching = False
if self.speculative_config is not None:
self.enable_prefix_caching = False
if not current_platform.is_cuda() and not current_platform.is_xpu() and not current_platform.is_intel_hpu():
self.enable_prefix_caching = False
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

这个改动启用了 MTP 的 prefix caching 功能,但是缺少相应的测试覆盖。虽然已有 tests/e2e/test_ernie_21b_mtp.py 测试 MTP 功能,但该测试没有明确验证 prefix caching 是否正常工作。

建议添加以下测试:

  1. 测试 MTP 启用 prefix caching 时的正确性(例如,多个请求共享相同前缀时的行为)
  2. 测试 prefix caching 对 MTP 性能的影响
  3. 验证 KV cache 的正确共享和管理

或者,如果现有的 e2e 测试已经隐式覆盖了这个场景,请在 PR 描述中说明测试是如何验证这个改动的。

Copilot uses AI. Check for mistakes.
Comment on lines 486 to 490
self.tokenizer = self.model
if self.splitwise_role == "decode":
self.enable_prefix_caching = False
if self.speculative_config is not None:
self.enable_prefix_caching = False
if not current_platform.is_cuda() and not current_platform.is_xpu() and not current_platform.is_intel_hpu():
self.enable_prefix_caching = False
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

根据自定义代码审查指南,PR 的描述信息不够完整。描述中只说明了"Enable prefix caching for mtp by default",但缺少以下关键信息:

  1. 为什么要做这个修改: 之前为什么禁用了 speculative_config 的 prefix caching?现在为什么可以启用?
  2. 如何验证修改的正确性: 是否进行了测试?测试结果如何?
  3. 潜在影响: 这个改动对现有使用 MTP 的用户有什么影响?

建议补充说明:

  • MTP 代码(如 fastdeploy/spec_decode/mtp.py 第 180 行)已经支持 prefix caching 的技术细节
  • 经过了哪些测试验证(准确性、性能等)
  • 是否有相关的 benchmark 数据支持这个改动

这些信息对于理解和审查这个功能性变更非常重要。

Copilot generated this review using guidance from repository custom instructions.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@8aec3ac). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5302   +/-   ##
==========================================
  Coverage           ?   59.04%           
==========================================
  Files              ?      322           
  Lines              ?    39196           
  Branches           ?     5888           
==========================================
  Hits               ?    23143           
  Misses             ?    14224           
  Partials           ?     1829           
Flag Coverage Δ
GPU 59.04% <ø> (?)

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.

2 participants