Summary
Add support for loading pre-quantized models (GPTQ, AWQ) via HuggingFace's native AutoHfQuantizer framework, enabling layer-by-layer inference of production-optimized quantized models.
Background
Most practical open-source models for the RTX 4070 (8GB VRAM) are distributed pre-quantized by their creators (TheBloke, etc.). These use GPTQ or AWQ formats which are already 4-bit on disk and optimized for quality. This is more important than runtime quantization (#1943) for production use.
airllm integrates HfQuantizer by:
- Reading
quantization_config from the model's HuggingFace config
- Creating a quantizer via
AutoHfQuantizer.from_config(config, pre_quantized=True)
- During layer loading, checking each parameter:
hf_quantizer.check_quantized_param()
- Creating quantized params in-place:
hf_quantizer.create_quantized_param()
# In init_model()
quantization_config = getattr(config, "quantization_config", None)
if quantization_config is not None:
self.hf_quantizer = AutoHfQuantizer.from_config(quantization_config, pre_quantized=True)
self.hf_quantizer.preprocess_model(model=self.model, device_map=device_map)
# In move_layer_to_device() — per parameter
if self.hf_quantizer.check_quantized_param(self.model, state_dict[param_name], param_name, ...):
self.hf_quantizer.create_quantized_param(self.model, state_dict[param_name], param_name, ...)
Key Files
autobot-backend/llm_interface_pkg/optimization/quantization.py — HfQuantizer integration
autobot-backend/llm_interface_pkg/providers/ — wire into local model providers
autobot-backend/llm_interface_pkg/optimization/router.py — detect and route pre-quantized models
Acceptance Criteria
Related Issues
Summary
Add support for loading pre-quantized models (GPTQ, AWQ) via HuggingFace's native
AutoHfQuantizerframework, enabling layer-by-layer inference of production-optimized quantized models.Background
Most practical open-source models for the RTX 4070 (8GB VRAM) are distributed pre-quantized by their creators (TheBloke, etc.). These use GPTQ or AWQ formats which are already 4-bit on disk and optimized for quality. This is more important than runtime quantization (#1943) for production use.
airllm integrates HfQuantizer by:
quantization_configfrom the model's HuggingFace configAutoHfQuantizer.from_config(config, pre_quantized=True)hf_quantizer.check_quantized_param()hf_quantizer.create_quantized_param()Key Files
autobot-backend/llm_interface_pkg/optimization/quantization.py— HfQuantizer integrationautobot-backend/llm_interface_pkg/providers/— wire into local model providersautobot-backend/llm_interface_pkg/optimization/router.py— detect and route pre-quantized modelsAcceptance Criteria
quantization_configRelated Issues