Prhub

#45454 [Refactor] Remove dead quantization code and tests

原始 PR 作者 yewentao256 合并时间 2026-06-18 04:12 文件变更 5 提交数 4 评论 0 代码增减 +0 / -120

执行摘要

移除无用量化代码和测试

PR body 仅标明移除死量化代码和测试。这样做可以减少代码库中无用的测试和已废弃的配置路径,避免误导开发者和 CI 资源浪费。

值得精读,可作为代码清理的理想范例:审慎移除标记为跳过或遗留的路径,保持代码库整洁。

讨论亮点

无 review 讨论。sfeng33 快速批准。

实现拆解

  1. 移除 FP8 KV cache 测试:删除 tests/quantization/test_fp8.py 中已标记跳过的 KV_CACHE_MODELS 列表和 test_kv_cache_model_load_and_run 函数,这些测试依赖已被移除的 checkpoint。
  2. 移除 FPQuant 测试:删除整个 tests/quantization/fp_quant.py 文件,该文件测试已不再支持的 FPQuant 方法。
  3. 移除 AWQ 已跳过测试:删除 tests/kernels/quantization/test_awq.py 中已标记跳过且需调查的 test_awq_gemm_opcheck 函数。
  4. 清理 fp8.py 死分支:移除 vllm/model_executor/layers/quantization/fp8.py 中冗余的 if self.use_marlin 分支,该分支逻辑与后续统一调用相同。
  5. 移除自动舍入配置键:从 vllm/model_executor/layers/quantization/__init__.py 中删除 "auto-round": INCConfig 映射,该配置已在 INC 重构后废弃。
文件 模块 状态 重要度
tests/quantization/test_fp8.py FP8 量化 modified 5.91
tests/quantization/fp_quant.py FP 量化 removed 5.29
tests/kernels/quantization/test_awq.py AWQ 量化 modified 4.89
vllm/model_executor/layers/quantization/fp8.py FP8 量化 modified 4.4
vllm/model_executor/layers/quantization/__init__.py 量化注册 modified 4.16

关键符号

test_kv_cache_model_load_and_run check_model test_fpquant test_awq_gemm_opcheck

关键源码片段

vllm/model_executor/layers/quantization/fp8.py core-logic

移除了 apply 方法中冗余的 if self.use_marlin 分支,简化了控制流。

# vllm/model_executor/layers/quantization/fp8.py (cleanup)
# 在 `apply` 方法尾部,去除了重复的 Marlin 分支
​
        # ... 前置逻辑:dequant 到 BF16 并执行 GEMM
        if weight_scale.dim() == 1 and weight_scale.shape[0] == weight_fp8.shape[0]:
            weight_bf16 = weight_fp8 * weight_scale.unsqueeze(1)
        else:
            weight_bf16 = weight_fp8 * weight_scale
        return torch.nn.functional.linear(x, weight_bf16.t(), bias)
​
    # 移除了以下死分支:
    # if self.use_marlin:
    # return self.fp8_linear.apply_weights(layer, x, bias)
    # 现在所有非 dequant 路径统一调用 :
    return self.fp8_linear.apply_weights(layer, x, bias)

评论区精华

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

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

风险与影响

移除已标记跳过的测试和死分支风险很低。但需要注意:如果任何外部代码或自定义路径依赖了 __init__.pyauto-round 键或 fp8.pyuse_marlin 标志,会引发配置错误。鉴于这些代码已被标记为废弃或跳过,影响面极小。

对用户无功能影响;对开发者减少了混淆,清洁了量化模块。CI 可能略微加速,因为移除了无用的测试数据加载。

配置兼容性 测试清理

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论