[Models] support swa for fleet fallback model - #8090
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8090 +/- ##
==========================================
Coverage ? 67.52%
==========================================
Files ? 475
Lines ? 66958
Branches ? 10329
==========================================
Hits ? 45213
Misses ? 18874
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-07-06 14:33:48
📋 Review 摘要
PR 概述:为 PaddleFleet fallback MLA 模型新增基于 window_attn_skip_freq 的 SWA/DSA attention 路径,并调整 fallback 初始化/测试。
变更范围:base_fleet.py、fallback 单测
影响面 Tag:[Models]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | fastdeploy/model_executor/models/paddleformers/base_fleet.py:178 |
新增 SWA 前向路径缺少 logits/精度对齐证据 |
| 🟡 建议 | tests/model_executor/fallback/test_fallback_fleet_model_coverge.py:1365 |
SWA 单测 mock 掉真实 DSA 且未校验真实入参 rank/shape |
📝 PR 规范检查
标题包含官方 [Models] Tag,描述包含 checklist.md §D2 要求的 Motivation、Modifications、Usage or Command、Accuracy Tests、Checklist 结构,符合规范。
总体评价
实现方向和 DeepSeek SWA/DSA 路径基本对齐,但当前验证主要停留在控制流/shape mock。建议补齐最小数值对齐和真实后端入参约束后再合入核心模型路径。
| forward_meta=forward_meta, | ||
| k_pos_emb_sq = k_pos_emb.squeeze(0) | ||
|
|
||
| if self.window_attn_skip_freq is not None and self.window_attn_skip_freq[self.layer_id] == 1: |
There was a problem hiding this comment.
🟡 建议 这里新增了 window_attn_skip_freq 命中的 MLA/SWA 层直接走 DSAAttentionBackend.forward_static 的前向路径,但 PR 只提供了 mock/shape 级单测,Accuracy Tests 也标为 N/A。该分支会改变 prefill/decode 的 mask、indexer、cache 写入和 softmax scale 使用,输出直接影响 logits;没有 fallback logits 或参考实现对齐,后续 get_swa_indexer_top_k、cache layout、V de-absorb 任一错误都不会被发现。
建议修复方式:
补一个小模型/固定 seed 的 PaddleFleet fallback SWA 对齐用例,至少覆盖 window_attn_skip_freq[layer_id] == 1 的 prefill-only 和 mixed prefill+decode,并与 DeepSeek/PaddleFleet 参考路径比较 logits 容差;如果 CI 无法跑真实 GPU kernel,请在 PR 中附可复现命令和对齐结果。
| query = paddle.randn([seq_len, num_heads, kv_lora_rank]) | ||
| key = paddle.randn([seq_len, num_heads, kv_lora_rank]) | ||
| value = paddle.randn([seq_len, num_heads, kv_lora_rank]) | ||
| kv_compressed = paddle.randn([1, seq_len, num_heads, kv_lora_rank]) |
There was a problem hiding this comment.
🟡 建议 这个用例把 DSAAttentionBackend.forward_static 整体替换成 MagicMock,同时构造的 kv_compressed squeeze 后是 3D [seq, heads, rank],但真实 DSA backend 要求 compressed_kv 为 2D、k_pe 为 3D。因此测试会在真实调用会触发 shape/rank 问题时仍然通过。
建议修复方式:
让用例使用真实后端约束的入参形状,例如 kv_compressed squeeze 后为 [seq, kv_lora_rank]、k_pos_emb squeeze 后为 [seq, 1, qk_rope_head_dim]、q_absorbed 最后一维为 kv_lora_rank + qk_rope_head_dim,并对 mock_dsa.forward_static.call_args 断言 q.ndim == 3、compressed_kv.ndim == 2、k_pe.ndim == 3。
|
Thanks for your contribution! |
Motivation
Support sliding-window attention (SWA) for PaddleFleet fallback MLA models, so SWA layers selected by
window_attn_skip_freqcan use the DSA attention path.Modifications
fastdeploy/model_executor/models/paddleformers/base_fleet.py: passwindow_attn_skip_freqandsliding_windowintoFastDeployAttention.fastdeploy/model_executor/models/paddleformers/base_fleet.py: add an SWA branch that buildsindexer_top_kand callsDSAAttentionBackend.forward_staticfor MLA attention.fastdeploy/model_executor/models/paddleformers/base_fleet.py: adjust PaddleFleet fallback config/model loading and MoE-related config fields.Usage or Command
N/A
Accuracy Tests
N/A(当前 PR 未提供 SWA/fallback logits 对齐或精度测试结果)
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.