Prhub

#34100 [Fix] Give the piecewise CUDA graph test stub an `hf_config`

原始 PR 作者 hnyls2002 合并时间 2026-08-08 17:04 文件变更 1 提交数 2 评论 1 代码增减 +4 / -1

执行摘要

修复 piecewise CUDA graph 测试 stub 缺失 hf_config 导致的 CI 失败

PR body 明确指出 base-a-test-cpu 当前在 main 上红:test_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility 抛出 AttributeError: 'types.SimpleNamespace' object has no attribute 'hf_config'。原因是 #32785 在 _disable_breakable_cudagraph_if_incompatible 的 MLA 规则中新增了 is_deepseek_dsa(self.get_model_config().hf_config) 项,但该测试的 stub 只设置了 is_multimodal_piecewise_cuda_graph_supported。由于该文件内只有这个用例 patch 了 use_mla_backend 为 True,因此只有它穿过短路逻辑触及新条款。

值得快速浏览以理解 piecewise CUDA graph 兼容性规则如何读取 hf_config,以及测试 stub 需要跟随生产逻辑同步更新。但整体改动直白,无精读必要。

讨论亮点

没有 review 评论线程。PR body 中作者说明了两个关键决策:一是只有 test_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility 会穿过短路达到新条款,因此只需修这一个 stub;二是选择 DeepseekV2ForCausalLM 作为架构,因为它代表 MLA 而非 DSA,正好对应测试断言期望的 DISABLED 后端。

实现拆解

本次变更仅涉及 1 个测试文件,实施步骤如下:

  1. 定位失败根因test/registered/unit/configs/test_multimodal_piecewise_cuda_graph.pytest_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility 构造的 SimpleNamespace stub 只包含 is_multimodal_piecewise_cuda_graph_supported,缺少 hf_config 属性;而 #32785 引入的 MLA 兼容性规则会读取 hf_config 做 DSA 豁免判断,导致 AttributeError

  2. 补齐 stub 属性:在 args.model_configSimpleNamespace 中追加 hf_config=SimpleNamespace(architectures=["DeepseekV2ForCausalLM"])。该架构满足“MLA 但非 DSA”的条件,与断言期望的 prefill.backend == Backend.DISABLED 一致。PR body 还说明这与同文件 test_embedding_gemma_forces_breakable_prefill 的 stub 构建方式一致。

  3. 无源码主路径改动:本 PR 仅修复测试配置,不涉及 ServerArgs、兼容性规则或任何生产代码,因此不影响运行时行为。

文件 模块 状态 重要度
test/registered/unit/configs/test_multimodal_piecewise_cuda_graph.py 配置测试 modified 4.06

关键符号

test_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility

关键源码片段

test/registered/unit/configs/test_multimodal_piecewise_cuda_graph.py test-coverage

唯一变更文件,修复 `test_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility` 中 stub 缺失 `hf_config` 导致的 AttributeError,使 CI 恢复绿色。

# test/registered/unit/configs/test_multimodal_piecewise_cuda_graph.pydef test_trtllm_mla_stays_on_breakable_and_is_disabled_by_compatibility(self):
    args = ServerArgs(model_path="dummy")
    # The MLA rule reads hf_config to exempt DSA models, so the stub needs
    # an architecture that is MLA but not DSA.
    args.model_config = SimpleNamespace(
        is_multimodal_piecewise_cuda_graph_supported=True,
        hf_config=SimpleNamespace(architectures=["DeepseekV2ForCausalLM"]),
    )
    args.cuda_graph_config = CudaGraphConfig(
        prefill=PhaseConfig(backend=Backend.BREAKABLE)
    )
    args._cuda_graph_config_locked = set()
​
    with (
        patch.object(
            args,
            "_resolved_attention_backends",
            return_value=("trtllm_mla", "trtllm_mla"),
        ),
        patch.object(args, "use_mla_backend", return_value=True),
    ):
        args._apply_cuda_graph_compatibility()
​
    self.assertEqual(args.cuda_graph_config.prefill.backend, Backend.DISABLED)

评论区精华

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

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

风险与影响

风险极低,因为变更仅限测试 stub,不触碰生产逻辑。但有两个潜在注意点:

  • 测试 stub 与真实模型配置的耦合:未来若 hf_config 结构变化(如 architectures 字段改名),该测试会再次失效,且这种失败不会被生产代码触发,需要靠 CI 捕获。
  • 该测试依赖 trtllm_mla backend 在测试环境中的可用性,若 backend 名称变更或移除,同样可能造成测试失败。

影响范围很小:修复了 CI 基线(base-a-test-cpu)的红灯,恢复开发者对分支状态的正确感知,提升 CI 可信度。对用户无运行时影响,对团队是低成本的维护性改进。

测试 stub 与生产配置耦合 依赖 trtllm_mla backend 可用性

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论