clean code#8044
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8044 +/- ##
==========================================
Coverage ? 67.39%
==========================================
Files ? 475
Lines ? 66708
Branches ? 10288
==========================================
Hits ? 44959
Misses ? 18878
Partials ? 2871
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-06-15 17:00:38
📋 Review 摘要
PR 概述:重构 DSA attention 的 KV 构造和静态 forward 路径,并新增未启用的 SWA indexer helper,同时删除原 DSA backend 单测文件。
变更范围:fastdeploy/model_executor/layers/attention/、fastdeploy/model_executor/models/、tests/layers/
影响面 Tag:[Models] [OP]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | fastdeploy/model_executor/layers/attention/dsa_attention_backend.py:344 |
新增 forward_static() 承接核心 DSA 前向路径,但对应 forward/mixed 分支测试被整体删除且无替代覆盖 |
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | 这个 fallback 分支当前被 if False 保护,但其中取 latent cache 的下标和 DSA cache 布局不一致。 |
📝 PR 规范检查
标题缺少官方 Tag,PR 描述保留了模板占位内容,Checklist 未按本次变更更新。可直接替换为以下内容。
标题建议(可直接复制):
[OP] Refactor DSA attention KV construction
PR 描述建议(点击展开,可直接复制)
## Motivation
重构 DSA attention 的 KV 输入构造和 backend 静态调用路径,减少 DeepSeekV3 DSA 模型侧重复拼接 KV 的逻辑。
## Modifications
- 在 `DSAAttentionBackend` 中新增 `forward_static()`,由 backend 统一写入 DSA KV cache、拼接 `compressed_kv` 与 `k_pe`,并处理 prefill/decode 的 flash_mla 调用。
- 在 `DeepseekV32DSAAttention.forward()` 中移除模型侧 `kv` 拼接和 `k` 参数传递,改为只传 `compressed_kv`、`k_pe` 与 `indexer_top_k`。
- 新增一个当前未启用的 SWA indexer top-k Triton helper 和 DSA fallback 分支。
## 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.
- [x] 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.总体评价
主路径重构本身没有发现新的阻塞性逻辑错误;但新增 forward_static() 覆盖了 DSA prefill/decode/mixed 的核心行为,删除原测试后需要补齐最小回归保护。历史 finding F1 对应的 if False 分支仍在当前 diff 中,且仍使用 forward_meta.caches[self.layer_id]。
| return res | ||
|
|
||
| @staticmethod | ||
| def forward_static( |
There was a problem hiding this comment.
🟡 建议 这个新增的 forward_static() 承接了 DSA 的 cache 写入、prefill、decode 和 mixed merge 逻辑,但本 PR 同时删除了原来覆盖 forward_mixed 分支的 tests/layers/test_dsa_attention_backend.py,没有补充替代测试。
当前保留的 tests/layers/test_dsa_attention_kv_cache.py 只覆盖 cache shape/create_host_kv_cache,无法守住这里的输出 shape、cache 写入和 indexer_topk 传参。建议保留或重写轻量单测,至少覆盖 prefill-only、decode-only、prefill+decode merge 三条分支,并 mock flash_mla/dsk_attn_write_cache 验证 compressed_kv + k_pe 在 backend 内构造后的调用参数。
CI报告基于以下代码生成(30分钟更新一次): 1 Required任务 : 9/10 通过
2 失败详情🔴 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — PR问题(置信度: 高)错误类型: PR问题 | 置信度: 高
关键日志:
修复建议:
关联变更: |
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist
[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]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.