# PR #21195 完整报告

- 仓库：`sgl-project/sglang`
- 标题：Enable the qwen3 test
- 合并时间：2026-03-24 14:40
- 原文链接：http://prhub.com.cn/sgl-project/sglang/pull/21195

---

## 执行摘要
本 PR 通过修正 Qwen3 MoE 模型的专家并行性 all-reduce 逻辑并重新启用 CI 测试，旨在提升分布式计算正确性和测试覆盖率。然而，review 中指出了 all-reduce 条件的潜在错误，合并后仍存在风险，建议开发者关注后续修正。

## 功能与动机
PR 的主要动机是启用之前被禁用的 Qwen3 30B 模型测试，并修正模型中的专家并行性 all-reduce 操作。根据 Issue 评论，变更旨在确保在分布式专家并行性设置下，模型前向传播的正确性，避免因 all-reduce 缺失导致计算结果错误。

## 实现拆解
实现涉及两个关键文件变更：
1. **`python/sglang/srt/models/qwen3_moe.py`**：在 `forward_normal` 函数中添加代码块：
   ```python
   if self.ep_size > 1 and not should_allreduce_fusion:
       final_hidden_states = moe_expert_parallel_all_reduce(final_hidden_states)
   ```
 此变更处理专家并行性大于 1 时的 all-reduce 操作，但条件依赖于 `should_allreduce_fusion`。

2. **`test/registered/4-gpu-models/test_qwen3_30b.py`**：移除禁用注释 `disabled="Temporarily disable the flaky test."`，将测试重新注册到 CI 套件 `stage-c-test-4-gpu-h100`。

## 评论区精华
gemini-code-assist[bot] 在 review 中提出关键问题：
> ![critical](https://www.gstatic.com/codereviewagent/critical.svg) The new `moe_expert_parallel_all_reduce` call is correctly added to handle expert parallelism. However, conditioning it on `not should_allreduce_fusion` is problematic. `should_allreduce_fusion` is related to fusing the *tensor parallelism* all-reduce with the next layer's operations. When it's `True`, this expert parallelism all-reduce is skipped but not performed later, leading to incorrect results as the partial outputs from different expert parallel ranks are not summed up.

该讨论强调 all-reduce 条件可能设计不当，应独立于张量并行性 fusion 状态，但 PR 未采纳修正建议。

## 风险与影响
- **技术风险**：`not should_allreduce_fusion` 条件可能导致专家并行性 all-reduce 在 fusion 启用时被跳过，引发计算结果错误，影响模型准确性。
- **影响范围**：修正直接影响 Qwen3 MoE 模型在分布式环境下的输出；测试启用提高了 CI 自动化水平，但对用户感知有限，主要服务于开发团队。

## 关联脉络
从历史 PR 分析看，本 PR 与 PR 21267（禁用不稳定测试）同属测试维护范畴，反映团队对 CI 稳定性的关注。同时，PR 21019（Qwen3.5 性能优化）显示 Qwen 模型家族的持续演进，本 PR 为正确性基础工作。这些关联揭示仓库在测试和模型优化上的协同推进。