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-07-01 18:26:47 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 环境问题:Mooncake admin 端口 9003 启动失败 Job

2 失败详情

🔴 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — 环境问题(置信度: 高)

分析器: ci_analyze_unittest_fastdeploy

失败用例:

用例 错误摘要
tests/e2e/test_ernie_03b_pd_router_v1_rdma_global_cache.py Mooncake master 启动失败,admin server 无法启动 9003 端口

关键日志:

E... rpc_service.cpp:234] Failed to start master admin server on port 9003
E... master.cpp:1104] Failed to start master admin server
[ERROR] Mooncake Master failed to start
RuntimeError: Mooncake Master did not start
  • 根因摘要: Mooncake admin 端口 9003 启动失败
    coverage_run.sh 将该 job 的 exit code 8 标记为单测失败;失败列表只有 tests/e2e/test_ernie_03b_pd_router_v1_rdma_global_cache.py。该测试启动 mooncake_master 时 master 端口 8630 已启动,但 admin/metrics 端口 9003 启动失败,属于 CI 端口/环境冲突;PR 仅修改 fastdeploy/model_executor/layers/attention/mla_attention_backend.py,未改该 e2e 测试或端口逻辑。

修复建议:

  1. 环境问题,请 rerun;若重跑仍失败,清理 runner 上占用 9003 的残留进程,或让该测试的 Mooncake admin/metrics 端口跟随 FD_RDMA_PORT 动态分配。

关联变更: PR 仅修改 fastdeploy/model_executor/layers/attention/mla_attention_backend.py,与失败测试的 Mooncake 端口启动流程无直接关联。

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