[BUGFIX] patch_paged_attention_v2.py: NameError V2_MODULE undefined → V2_MODULE_PYTORCH

deploy_v2_module() 引用 V2_MODULE 但文件只定义了 V2_MODULE_PYTORCH 和 V2_MODULE_TRITON。
这导致 Docker build 时 NameError → V2 module 部署静默失败 → _custom_ops.py 的
V2 import 会 ImportError → V2 路径不可用。

修复: 4 处 V2_MODULE 引用全部改为 V2_MODULE_PYTORCH

影响: 如果 Dockerfile 启用了 V2 (patch_paged_attention_v2.py),
此 bug 意味着 V2 module 从未被正确部署。V2 的 import 总是失败,
paged_attn.py 的 V2 路径总是走到 except 分支。

这实际上是一个'幸运的 bug'——因为 V2 PyTorch 比 V1 ixformer 慢,
V2 部署失败反而保护了性能。但它也意味着如果未来需要 V2,
必须先修这个 bug。

功能测试影响: 无 (V2 不影响功能测试, V1 已够用)
效果测试影响: 正面 (V1 ixformer 精度一致性好于 V2 PyTorch)
This commit is contained in:
muh-bot
2026-08-05 07:07:54 +00:00
parent fd2ff241fb
commit cfa6516cc6

View File

@@ -144,17 +144,17 @@ def patch_paged_attn(vllm_root):
def deploy_v2_module(vllm_root):
"""Copy the V2 PyTorch module into the vllm package."""
src = os.path.join(os.path.dirname(__file__), "..", V2_MODULE)
src = os.path.join(os.path.dirname(__file__), "..", V2_MODULE_PYTORCH)
if not os.path.exists(src):
src = os.path.join("/workspace", V2_MODULE)
src = os.path.join("/workspace", V2_MODULE_PYTORCH)
if not os.path.exists(src):
# Try relative to this script
src = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", V2_MODULE)
src = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", V2_MODULE_PYTORCH)
dst = os.path.join(vllm_root, V2_MODULE)
dst = os.path.join(vllm_root, V2_MODULE_PYTORCH)
if os.path.exists(dst):
print(f" [skip] {dst} already exists")
print(f" [skip] V2 module {dst} already exists")
return True
if not os.path.exists(src):
@@ -162,7 +162,7 @@ def deploy_v2_module(vllm_root):
return False
shutil.copy2(src, dst)
print(f" [ok] Copied {V2_MODULE}{dst}")
print(f" [ok] Copied {V2_MODULE_PYTORCH}{dst}")
return True