__init__.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from typing import Type
  2. from loguru import logger
  3. from aphrodite.quantization.aqlm import AQLMConfig
  4. from aphrodite.quantization.awq import AWQConfig
  5. from aphrodite.quantization.base_config import \
  6. QuantizationConfig
  7. from aphrodite.quantization.bitsandbytes import \
  8. BitsandBytesConfig
  9. from aphrodite.quantization.eetq import EETQConfig
  10. from aphrodite.quantization.exl2 import Exl2Config
  11. from aphrodite.quantization.gguf import GGUFConfig
  12. from aphrodite.quantization.gptq import GPTQConfig
  13. from aphrodite.quantization.marlin import MarlinConfig
  14. from aphrodite.quantization.quip import QuipConfig
  15. from aphrodite.quantization.squeezellm import SqueezeLLMConfig
  16. try:
  17. from aphrodite._quant_C import quant_ops # noqa: F401
  18. except ImportError:
  19. logger.warning("The Quantization Kernels are not installed. "
  20. "To use quantization with Aphrodite, make sure "
  21. "you've exported the `APHRODITE_INSTALL_QUANT_KERNELS=1`"
  22. "environment variable during the compilation process.")
  23. _QUANTIZATION_CONFIG_REGISTRY = {
  24. "aqlm": AQLMConfig,
  25. "awq": AWQConfig,
  26. "bnb": BitsandBytesConfig,
  27. "eetq": EETQConfig,
  28. "exl2": Exl2Config,
  29. "gguf": GGUFConfig,
  30. "gptq": GPTQConfig,
  31. "quip": QuipConfig,
  32. "squeezellm": SqueezeLLMConfig,
  33. "marlin": MarlinConfig,
  34. }
  35. def get_quantization_config(quantization: str) -> Type[QuantizationConfig]:
  36. if quantization not in _QUANTIZATION_CONFIG_REGISTRY:
  37. raise ValueError(f"Invalid quantization method: {quantization}")
  38. return _QUANTIZATION_CONFIG_REGISTRY[quantization]
  39. __all__ = [
  40. "QuantizationConfig",
  41. "get_quantization_config",
  42. ]