Prhub

#49351 [CI][Bugfix] Reduce max_model_len in OOT embedding test to fix KV-cache OOM on small GPUs

原始 PR 作者 sfeng33 合并时间 2026-07-22 03:00 文件变更 1 提交数 1 评论 0 代码增减 +1 / -1

执行摘要

降低 embedding 测试的 max_model_len 修复 OOM

关联 Issue #49333 报告了 CI 测试 test_oot_registration_embedding 在 L4 GPU 上因 KV cache 内存不足而失败:模型权重和 CUDA graph 内存预留 (0.50 GiB) 后只剩下 0.64 GiB,而 max_model_len=2048 需要 0.66 GiB。PR body 确认测试只嵌入两个短 prompt,实际不需要长序列,因此通过降低 max_model_len 解决。

可以直接合并。这是一个简单且安全的测试修复,通过调整测试配置避免 CI 硬件限制导致的失败。

讨论亮点

无人工 review 评论;yewentao256 直接批准,claude[bot] 自动评论因来自 fork 而跳过检查。

实现拆解

  1. tests/plugins_tests/test_oot_registration_offline.pytest_oot_registration_embedding 函数中,将 LLM 初始化参数 max_model_len2048 改为 512
  2. 这个改动使 KV cache 需求从 0.66 GiB 降至约 0.17 GiB,确保在 L4 GPU 的剩余 0.64 GiB KV cache 内存内可以启动。
  3. 由于测试只嵌入两个约 7-token 的 prompt,max_model_len=512 完全满足测试需求,不会改变测试语义或输出。
文件 模块 状态 重要度
tests/plugins_tests/test_oot_registration_offline.py 测试 modified 3.42

关键符号

test_oot_registration_embedding

关键源码片段

tests/plugins_tests/test_oot_registration_offline.py test-coverage

唯一变更文件,将 max_model_len 从 2048 降低到 512,修复 KV cache OOM。

# tests/plugins_tests/test_oot_registration_offline.py
@create_new_process_for_each_test()
def test_oot_registration_embedding(
    monkeypatch: pytest.MonkeyPatch,
    dummy_gemma2_embedding_path: str,
):
    with monkeypatch.context() as m:
        m.setenv("VLLM_PLUGINS", "register_dummy_model")
        prompts = ["Hello, my name is", "The text does not matter"]
        llm = LLM(
            model=dummy_gemma2_embedding_path,
            load_format="dummy",
            # 降低 max_model_len 以减少 KV cache 需求,避免小 GPU 上 OOM
            # 原值 2048 需要 0.66 GiB KV cache,但 L4 GPU 只剩 0.64 GiB
            max_model_len=512, # 只需 0.17 GiB,远低于可用内存
        )
        outputs = llm.embed(prompts)
​
        for output in outputs:
            assert all(v == 0 for v in output.outputs.embedding)

评论区精华

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

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

风险与影响

风险极低。仅修改测试参数,测试逻辑和断言不变。若未来某个 embedding 模型需要更长的序列进行测试,该参数可能需要重新调整,但当前测试场景不涉及长序列。

仅影响 CI 中的 test_oot_registration_embedding 测试,使其能在 L4 等小显存 GPU 上通过。不改变任何生产代码或 API 行为。

测试配置变更 硬件相关失败

关联 Issue

#49333 [CI Failure]: Plugin Tests (2 GPUs)

完整报告

参与讨论