AttributeError: ‘types.SimpleNamespace’ object has no attribute ‘tp_shard_with_padding’

这个报错通常出现在 vLLM 的 MoE 权重加载路径读取 moe_config.tp_shard_with_padding 时,测试桩中的 SimpleNamespace 配置没有定义该属性。优先排查测试/调用方传入的 MoE 配置是否包含 tp_shard_with_padding ,它与 pa

快速结论:这个报错通常出现在 vLLM 的 MoE 权重加载路径读取 moe_config.tp_shard_with_padding 时,测试桩中的 SimpleNamespace 配置没有定义该属性。优先排查测试/调用方传入的 MoE 配置是否包含 tp_shard_with_padding,它与 padded 权重加载逻辑是否匹配。

适用环境:Issue 确认可在 CPU-only 本地复现;CI 上在 amd-mi300nvidia-h200-mig-35gb 同样失败;影响 vLLM main 分支 tip 78fdf4ef 及该提交之后的组合。Issue 未提供 Python、CUDA、PyTorch、ROCm 的具体版本号。

最快修复方案:升级/同步到已修复 main#57402 已在测试桩的 SimpleNamespace 配置中补充 tp_shard_with_padding。若你在维护自己的测试桩,可优先尝试按同样思路补上该属性。

注意事项:该修复针对的是测试桩配置缺失,不是 vLLM 运行时 MoE 内核本身的问题。若你的自定义配置里使用了 padded MoE,tp_shard_with_padding 的取值仍需与 padded 参数语义保持一致;否则可能掩盖真实的配置错误。

问题场景

在 vLLM 仓库中运行模型执行器相关测试时触发,具体为 model_executor/model_loader/test_reload.py::test_padded_moe_reload_releases_each_layer,覆盖全部 16 个参数化用例。该测试会构造一个 Stub MoE 配置并调用权重加载路径,而 padded 权重加载逻辑新增了对 moe_config.tp_shard_with_padding 的读取,测试桩未同步该字段。

报错原文

tests/model_executor/model_loader/test_reload.py:553: in test_padded_moe_reload_releases_each_layer
    layer.weight_loader(expected[name], weight, name, shard, expert)
vllm/model_executor/layers/fused_moe/routed_experts.py:877: in weight_loader
    self._load_model_weight_or_group_weight_scale(
vllm/model_executor/layers/fused_moe/routed_experts.py:349: in _load_model_weight_or_group_weight_scale
    padded_tp = self.moe_config.tp_shard_with_padding
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AttributeError: 'types.SimpleNamespace' object has no attribute 'tp_shard_with_padding'

原因分析

确定为两个 PR 合并到 main 后产生的语义冲突:#55867(08633cb5)在 _load_model_weight_or_group_weight_scale 中新增了 self.moe_config.tp_shard_with_padding 读取;#54699(78fdf4ef)新增了 test_padded_moe_reload_releases_each_layer,其 SimpleNamespace 配置桩在该读取逻辑合入之前构建,未设置该属性。两个 PR 各自基于自己的 base 均能通过,合并到 main 后组合失败。

环境排查

  • 确认当前 vLLM 代码是否包含 #57402 的修复;未包含时该测试在 main tip 78fdf4ef 上确定失败。
  • 确认失败测试文件与权重加载路径是否来自同一次同步:tests/model_executor/model_loader/test_reload.pyvllm/model_executor/layers/fused_moe/routed_experts.py
  • 确认测试桩 SimpleNamespace 构造的 MoE 配置中是否存在 tp_shard_with_padding 字段。
  • Issue 未提供 Python、CUDA、PyTorch、ROCm 或显卡驱动版本,无需据此排查。

解决步骤

  1. 将 vLLM 代码同步或更新到包含 #57402main;该 PR 已把 tp_shard_with_padding 加入测试的 SimpleNamespace 配置。
  2. 若不便于直接升级,可在本地测试桩中为 MoE 配置补充 tp_shard_with_padding;Issue 中建议值为 False,或按 padded 参数设置对应的合适值。
  3. 在 CPU-only 环境按 Issue 给出的命令复跑:pytest "tests/model_executor/model_loader/test_reload.py::test_padded_moe_reload_releases_each_layer" -q

验证方法

在修复后的代码上运行上述 pytest 命令,确认 16 个参数化用例全部通过。Issue 中已确认当前 main tip d12c2768 下全部 16 个参数通过,并据此将问题关闭为 completed。

参考来源

vllm-project/vllm #57483

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

这个方案解决了吗?

celebrityanime
celebrityanime
文章: 24144

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注