2025-02-02 14:58:18 -05:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2025-06-03 11:20:17 -07:00
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
2025-02-02 14:58:18 -05:00
|
|
|
|
2024-11-20 18:36:33 -08:00
|
|
|
from vllm.model_executor.layers.quantization import get_quantization_config
|
2024-07-02 20:12:22 -07:00
|
|
|
from vllm.platforms import current_platform
|
2024-06-13 11:18:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_quant_method_supported(quant_method: str) -> bool:
|
|
|
|
|
# Currently, all quantization methods require Nvidia or AMD GPUs
|
2024-09-13 02:20:14 -07:00
|
|
|
if not (current_platform.is_cuda() or current_platform.is_rocm()):
|
2024-06-13 11:18:08 -04:00
|
|
|
return False
|
|
|
|
|
|
2026-01-11 01:19:46 -06:00
|
|
|
try:
|
|
|
|
|
current_platform.verify_quantization(quant_method)
|
|
|
|
|
except ValueError:
|
|
|
|
|
return False
|
|
|
|
|
|
2024-07-02 20:12:22 -07:00
|
|
|
capability = current_platform.get_device_capability()
|
2024-09-18 18:38:11 +08:00
|
|
|
assert capability is not None
|
|
|
|
|
|
2024-11-20 18:36:33 -08:00
|
|
|
min_capability = get_quantization_config(quant_method).get_min_capability()
|
2024-09-18 18:38:11 +08:00
|
|
|
|
|
|
|
|
return capability.to_int() >= min_capability
|