Skip to content

swa#8054

Open
zhoutianzi666 wants to merge 1 commit into
PaddlePaddle:developfrom
zhoutianzi666:support_swa_mha1
Open

swa#8054
zhoutianzi666 wants to merge 1 commit into
PaddlePaddle:developfrom
zhoutianzi666:support_swa_mha1

Conversation

@zhoutianzi666

Copy link
Copy Markdown
Collaborator

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

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.

@zhoutianzi666 zhoutianzi666 changed the title commit swa Jun 16, 2026

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Paddle-CI-Agent | pr_review | 2026-06-16 14:07:55

📋 Review 摘要

PR 概述:调整 MLA attention baseline 的 causal / sliding-window mask 构造。
变更范围fastdeploy/model_executor/layers/attention/mla_attention_backend.py
影响面 Tag[OP]

问题

级别 文件 概述
🔴 Bug fastdeploy/model_executor/layers/attention/mla_attention_backend.py:878 SM10 MLA mixed prefill 固定传 window_size=-1,SWA 层仍执行 full attention

📝 PR 规范检查

PR 标题缺少官方 Tag,描述仍保留模板占位内容且未填写核心章节。建议替换为以下内容。

标题建议(可直接复制):

  • [OP] Fix MLA baseline SWA mask propagation
PR 描述建议(点击展开,可直接复制)
## Motivation
完善 MLA attention baseline 在 mixed prefill / prefix cache 场景下的 causal/SWA mask 构造,避免 cached KV 与当前 query 长度不一致时 mask 语义错误。

## Modifications
-`MLAAttentionBackend.mha_baseline` 中新增 `window_size` 参数。
-`kv_len - q_len + i + 1` 计算当前 query 可见的 KV 边界,并在 `window_size > 0` 时限制可见窗口。
- SM10 mixed prefill 分支调用 `mha_baseline` 时补充 `window_size` 形参。

## Usage or Command
N/A

## Accuracy Tests
N/A(当前 PR 未提供精度结果)

## 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.
- [ ] 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.

总体评价

代码变更方向是修正 MLA baseline mask,但调用点没有传递已有 SWA 层窗口,会让新增逻辑在目标场景失效。请先修复该语义传递;规范问题也需补齐。

forward_meta.cu_seqlens_q,
forward_meta.cu_seqlens_k,
causal=self.causal,
window_size=-1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug 这里把 window_size 固定为 -1,导致新增的 SWA mask 分支不会在唯一调用点生效。

Attention 层已经在 layer_types == "sliding_attention" 时保存了 layer.sliding_windowappend_attn_backend 也会把正的 sliding_window 传给 attention kernel;但 SM10 的 MLA mixed prefill 会走这个 mha_baseline 分支,当前固定 -1 后即使该层是 sliding attention,也会执行 full causal attention,输出语义和 SWA 配置不一致。

建议修复方式:在调用前按现有 attention 约定计算当前层窗口,例如 sliding 层传 layer.sliding_window(或与 append backend 一致地优先使用 backend/model 级 self.sliding_window),非 sliding 层传 -1/0 表示 full attention,并补充 kv_len > q_len 的 mixed prefill + SWA 对齐测试。

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@02a0042). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...executor/layers/attention/mla_attention_backend.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #8054   +/-   ##
==========================================
  Coverage           ?   67.50%           
==========================================
  Files              ?      475           
  Lines              ?    66660           
  Branches           ?    10284           
==========================================
  Hits               ?    45000           
  Misses             ?    18789           
  Partials           ?     2871           
Flag Coverage Δ
GPU 77.48% <20.00%> (?)
XPU 6.98% <0.00%> (?)

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

☔ View full report in Codecov by Harness.
📢 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.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jun 16, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-06-25 20:37:57 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 8222968 | Merge base: 02a0042 (branch: develop)


1 Required任务 : 9/10 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
41(0) 41 36 5 0 0 0
任务 错误类型 置信度 日志
Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage 未知 Job

2 失败详情

🔴 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — 未知(置信度: 低)

错误类型: 未知 | 置信度: 低
分析器: 通用分析(fallback)
失败用例: 未能从 CI 日志提取具体失败用例

用例 错误摘要
未知 scripts/coverage_run.sh 返回非 0,workflow 将其映射为 exit code 8

关键日志:

fetch_ci_logs: 日志获取失败,无法提取错误信息
GitHub Actions: Process completed with exit code 8.
  • 根因摘要: 测试执行失败但详细日志缺失
    Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage.github/workflows/_unit_test_coverage.yml 中执行 bash scripts/coverage_run.sh;该脚本发现失败测试后会 exit 8。本次深度日志没有 log_file_path / unittest_details / unittest_logs_dir,且返回的 extract_dir 在本机不存在,因此无法确认具体 pytest 用例。PR 仅修改 fastdeploy/model_executor/layers/attention/mla_attention_backend.py 的 Blackwell MHA baseline 参数与 mask 逻辑,存在与测试失败的相关风险,但缺少日志证据,不能定为 PR 根因。

修复建议:

  1. 先 rerun 或补齐该 job 的 unittest 日志,定位 failed_tests.log 中具体 pytest 文件。
  2. 若失败用例指向 MLA/Blackwell attention,优先检查 mha_baseline 新增 window_size 参数与 flash_attn_kwargs 的关键字兼容性,以及 kv_len - q_len + i + 1 mask 边界。
  3. 如果日志显示与 MLA 无关,再按具体失败用例处理,本轮不建议基于缺失日志直接改代码。

关联变更: fastdeploy/model_executor/layers/attention/mla_attention_backend.pyforward_mixed 调用参数、mha_baseline mask 逻辑)

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