Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions knowledge/repos/vllm-omni/components/diffusion/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ shared RMSNorm 的empty-input与fused精度边界沿 tensor dtype rules 的DIFF-
- [Diffusion JIT CUDA 构建 include 顺序规则](rules-jit-cuda-includes.md)
- [AR-Diffusion 实时模型集成规则](rules-ar-realtime-integration.md)
- [Diffusion attention dense 4D mask routing](rules-4d-mask-routing.md)
- [vllm-omni · Diffusion — Wan SDPA 对齐测试规则](rules-wan-sdpa-math.md)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Route the Wan SDPA rule through Direct

When a PR changes tests/diffusion/distributed/test_wan_attention_sdpa_alignment.py, direct_review_plan currently either returns the diffusion owner's components/diffusion/rules.md quick map without this rule or, without matching title/body text, returns no route; related_knowledge also excludes rule pages. Because this commit links the new rule only from _index.md, which reviewers must not reopen after an exact route, the MATH/torch.equal guard is never delivered. Add it to the owner rule or its Direct quick map, and route the test path if it must work independently of title/body wording.

AGENTS.md reference: knowledge/AGENTS.md:L16-L16

Useful? React with 👍 / 👎.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "vllm-omni · Diffusion — Wan SDPA 对齐测试规则"
created: 2026-10-23
updated: 2026-10-23
type: rule
tags: [vllm-omni, components, diffusion]
sources: ["PR #9303"]
---

# vllm-omni · Diffusion — Wan SDPA 对齐测试规则

## VLLM-OMNI-PR9303-WAN-SDPA-MATH — Wan SDPA 对齐测试须在 MATH 后端下逐位比较并保留负向对照

- 触发:改动 `tests/diffusion/distributed/test_wan_attention_sdpa_alignment.py` 中对 `install_wan_attention_sdpa_alignment` 后前向与 `_reference_attention`(diffusers 0.40.0 数学参考)的取值比较——特别是 `torch.equal` 断言是否包在 `sdpa_kernel(SDPBackend.MATH)` 上下文中,或增删 `_math_sdpa` / `_assert_matches_unaligned_math` 辅助函数与 `test_math_reference_rejects_value_changing_alignment` 负向对照。
- 强制:所有“重排后前向与未对齐参考逐位相等”的断言必须在 `torch.nn.attention.sdpa_kernel(SDPBackend.MATH)` 上下文内执行两侧前向,且仍要求 `torch.equal` 精确相等。依据:ROCm 默认 SDPA 后端对错位的 1x1 query 与重打包副本不逐位一致(AMD build 14494 中 shards 3/5–5/5 失败);测试要验证的是重排保值(realignment preserves values),不是厂商 kernel 的布局不变性,生产 kernel 不变。比较器必须保留负向对照:monkeypatch `wan_sdpa_alignment.align_sdpa_qkv` 令返回的 value 加 1 后,同一断言必须抛 AssertionError,证明精确比较器能拒绝改变取值的重排。对未验证 diffusers 版本的告警用例同样经 `_assert_matches_unaligned_math` 比较取值。
- 禁止:在默认(ROCm 实现相关的)SDPA 后端下直接做 `torch.equal` 取值断言;把断言放宽为近似容差(如 allclose)来绕开后端差异;删除 MATH 上下文、`_assert_matches_unaligned_math` 或篡改 value 的负向用例;把本规则解读为要求生产路径改用 MATH 后端——它只约束测试比较方式。
- 验收:`tests/diffusion/distributed/test_wan_attention_sdpa_alignment.py` 中取值断言均经 `_assert_matches_unaligned_math`(内部 `sdpa_kernel(SDPBackend.MATH)` + `torch.equal`);`test_math_reference_rejects_value_changing_alignment` 存在并以 `pytest.raises(AssertionError)` 期望失败;`pytest tests/diffusion/distributed/test_wan_attention_sdpa_alignment.py` 通过(PR #9303 记录本地 32 passed;AMD READY diffusion 分片按 PR 计划在 CI 复核)。^[PR #9303]

<!-- kb:rule status=active since=v0.30.0 -->
Loading