执行摘要
- 一句话:XPU pass_config.fuse_norm_quant断言修复
- 推荐动作:该PR是常规的平台适配bug修复,代码量小,逻辑清晰,值得快速合并。对于关注XPU支持的开发者,可以了解平台条件检查的模式。
功能与动机
修复XPU上运行测试时遇到的 AssertionError: pass_config.fuse_norm_quant: expected True, got False。PR body 明确指出了受影响的测试:tests/test_config.py::test_vllm_config_defaults[RedHatAI/Qwen3-8B-speculator.eagle3-compilation_config5-2]、test_vllm_config_explicit_overrides、test_fusion_pass_op_priority。
实现拆解
- 修改条件检查:在
vllm/config/compilation.py 的 PassConfig.post_init 方法中,将原来的条件 if self.enable_qk_norm_rope_fusion and not current_platform.is_cuda_alike() 改为 if self.enable_qk_norm_rope_fusion and not (current_platform.is_cuda_alike() or current_platform.is_xpu()),使得XPU平台也被认为是支持的,从而不再禁用该fusion。
- 更新warning日志:将对应的warning消息从 "CUDA or ROCm" 更新为 "CUDA, ROCm or XPU",以准确反映支持的平台。
- 调整测试断言:在
tests/test_config.py 的 test_vllm_config_explicit_overrides 中,将原先的 assert config.compilation_config.pass_config.enable_qk_norm_rope_fusion is True 改为根据平台条件动态判断:current_platform.is_cuda_alike() or current_platform.is_xpu(),确保XPU上该字段为 True,其他非CUDA/XPU平台为 False。
关键文件:
vllm/config/compilation.py(模块 编译配置;类别 source;类型 core-logic): 核心修复文件,修改了 PassConfig.post_init 中的平台条件检查,将XPU纳入允许使用QK Norm+RoPE fusion的平台列表。
tests/test_config.py(模块 配置测试;类别 test;类型 test-coverage): 测试文件,更新了 test_vllm_config_explicit_overrides 中断言,使其根据平台动态判断,修复了在XPU上因硬编码 True 导致的断言失败。
关键符号:未识别
关键源码片段
vllm/config/compilation.py
核心修复文件,修改了 PassConfig.post_init 中的平台条件检查,将XPU纳入允许使用QK Norm+RoPE fusion的平台列表。
# vllm/config/compilation.py
class PassConfig:
...
def __post_init__(self) -> None:
# ... other validations ...
# 原先是 : if self.enable_qk_norm_rope_fusion and not current_platform.is_cuda_alike():
# 修复后 : 将 XPU 也作为支持的平台
if self.enable_qk_norm_rope_fusion and not (
current_platform.is_cuda_alike() or current_platform.is_xpu()
):
logger.warning_once(
"QK Norm + RoPE fusion enabled but the current platform is not "
"CUDA, ROCm or XPU. The fusion will be disabled."
)
self.enable_qk_norm_rope_fusion = False
# ... other validations ...
tests/test_config.py
测试文件,更新了 test_vllm_config_explicit_overrides 中断言,使其根据平台动态判断,修复了在XPU上因硬编码 True 导致的断言失败。
# tests/test_config.py
def test_vllm_config_explicit_overrides():
# ... 之前的设置 ...
pass_config = PassConfig(enable_qk_norm_rope_fusion=True)
compilation_config = CompilationConfig(
cudagraph_mode=CUDAGraphMode.NONE, pass_config=pass_config
)
config = VllmConfig(
model_config=quantized_model,
optimization_level=OptimizationLevel.O2,
compilation_config=compilation_config,
)
assert config.compilation_config.cudagraph_mode == CUDAGraphMode.NONE
# 原来硬编码为 True,现在根据平台动态判断
# 在 CUDA 或 XPU 上应为 True,其他平台为 False
assert config.compilation_config.pass_config.enable_qk_norm_rope_fusion is (
current_platform.is_cuda_alike() or current_platform.is_xpu()
)
# 模式检查不变
assert config.compilation_config.mode == CompilationMode.VLLM_COMPILE
评论区精华
PR 没有 review 评论讨论。审核由 jikunshang(批准)和 yewentao256(评论 LGTM)完成,claude[bot] 自动评论提示从 fork 发起,未进行自动审查。
风险与影响
- 风险:风险极低。变更仅在平台检查中添加了XPU,属于条件分支扩展,不影响CUDA/ROCm原有行为。测试断言改为动态判断,避免了硬编码 True 带来的平台兼容性问题。
- 影响:影响范围限定在XPU平台。修复后的代码使得XPU用户可以正常使用
enable_qk_norm_rope_fusion 功能,相关测试(test_vllm_config_explicit_overrides 等)在XPU上不再断言失败。对CUDA和ROCm无影响。
- 风险标记:暂无
关联脉络
- PR #46987 [XPU] [RMSNorm] revert weightless change on xpu: 同为XPU平台修复,涉及 vllm/kernels/xpu_ops.py,表明近期XPU有多项适配工作。
参与讨论