Prhub

#43486 [ROCm][Critical] Fix the GDN import bug

原始 PR 作者 tjtanaa 合并时间 2026-05-24 05:12 文件变更 2 提交数 1 评论 1 代码增减 +6 / -3

执行摘要

修复 ROCm Aiter 因 GDN 重命名导致的导入崩溃

修复因 PR #41126 (Mamba Refactoring) 导致的导入错误。当设置 VLLM_ROCM_USE_AITER=1 时,RocmAiterRMSNormQuantFusionPass 中的 from vllm.model_executor.layers.mamba.gdn_linear_attn import GatedDeltaNetAttention 失败,引发 ModuleNotFoundError,导致 EngineCore 崩溃(错误日志显示 File "rocm_aiter_fusion.py", line 563)。这是关键问题,因为它影响所有在 ROCm 上使用 AITER 的模型。

值得快速合并,属于关键回归修复。建议关注 PR #41126 中其他是否还有类似的陈旧导入路径。

讨论亮点

无实质性 review 讨论;bot 评论确认仅有解释性评论无问题,两位 reviewer 直接批准。作者在 issue 评论中关联了上游 PR #41126 并提醒检查 PR #40710 的优化是否受重构影响,但这部分未在此 PR 中处理。

实现拆解

  1. 更新融合 Pass 导入路径:在 vllm/compilation/passes/fusion/rocm_aiter_fusion.py 中将 from vllm.model_executor.layers.mamba.gdn_linear_attn import GatedDeltaNetAttention 改为 from vllm.model_executor.layers.mamba.gdn.base import GatedDeltaNetAttention
  2. 更新测试模拟导入路径:在 tests/compile/passes/test_fusion.py_MockGDNLayer 类中同步修改导入路径,确保 __class__ 赋值能正确指向新模块中的 GatedDeltaNetAttention
  3. 调整 get_layers_from_vllm_config 调用:将原来的一行调用拆分为多行,并添加 # type: ignore[type-abstract] 注释以抑制抽象类的类型检查警告,保持代码可读性。
文件 模块 状态 重要度
vllm/compilation/passes/fusion/rocm_aiter_fusion.py 融合 Pass modified 6.09
tests/compile/passes/test_fusion.py 融合 Pass modified 3.82

关键符号

RocmAiterRMSNormQuantFusionPass.__init__ _MockGDNLayer.__init__

关键源码片段

vllm/compilation/passes/fusion/rocm_aiter_fusion.py dependency-wiring

包含融合 pass 的核心逻辑;修复 GatedDeltaNetAttention 的导入路径以匹配 Mamba 重构后的新模块结构。

# vllm/compilation/passes/fusion/rocm_aiter_fusion.py ( 第 563-570 行 )
        # 修复 : 导入路径已从 gdn_linear_attn 更新为 gdn.base
        from vllm.model_executor.layers.mamba.gdn.base import (
            GatedDeltaNetAttention,
        )
​
        gdn_layers = get_layers_from_vllm_config(
            config,
            GatedDeltaNetAttention, # type: ignore[type-abstract] # 抽象类 , 禁止实例化
        )
tests/compile/passes/test_fusion.py test-coverage

测试文件中的 _MockGDNLayer 模拟类使用相同的导入路径,必须同步更新以确保 unittest 通过。

# tests/compile/passes/test_fusion.py ( 第 524-528 行 )
    def __init__(self, num_v_heads: int, head_v_dim: int, tp_size: int = 1):
        self.num_v_heads = num_v_heads
        self.head_v_dim = head_v_dim
        self.tp_size = tp_size
        # 同步更新 import 路径以匹配源代码重构
        from vllm.model_executor.layers.mamba.gdn.base import (
            GatedDeltaNetAttention,
        )
        self.__class__ = GatedDeltaNetAttention

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

低风险。仅涉及导入路径修改和少量注释调整。如果新路径错误,会导致相同崩溃,但路径已在 PR body 中测试通过。测试覆盖了特定融合 pass。潜在风险是,如果未来再次移动 GatedDeltaNetAttention,需要同步更新此文件。

影响范围:直接修复 ROCm AITER 功能的回归问题。影响所有在 ROCm 上使用 VLLM_ROCM_USE_AITER=1 的模型,包括 Qwen3-Next 等大型模型。无用户界面或 API 变更,仅恢复已有功能。对非 ROCm 或未启用 AITER 的场景无影响。

依赖关系变更 关键路径回归

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论