[Core] Unified quantization framework (#1764)
This commit is contained in:
1 parent
2a630313ce
commit
6b93459826
40 files changed
+3306
-605
No files matched your search
@@ -260,7 +260,7 @@ class DiffusersPipelineLoader:
|
||||
) -> nn.Module:
|
||||
"""Load a model with the given configurations."""
|
||||
# CPU offload + FP8: load weights on device for FP8 quantization
|
||||
if load_device == "cpu" and od_config.quantization and od_config.quantization.lower() != "none":
|
||||
if load_device == "cpu" and od_config.quantization_config is not None:
|
||||
load_device = device.type
|
||||
logger.info(f"Quantization enabled with CPU offload, using {load_device} for weight loading")
|
||||
|
||||
@@ -342,28 +342,35 @@ class DiffusersPipelineLoader:
|
||||
quant_config = od_config.quantization_config
|
||||
if quant_config is None:
|
||||
return False
|
||||
# Fast path: mapping-style config (e.g., DictConfig)
|
||||
if isinstance(quant_config, dict):
|
||||
method = str(quant_config.get("method", "")).lower()
|
||||
if method != "gguf":
|
||||
return False
|
||||
gguf_model = quant_config.get("gguf_model")
|
||||
if not gguf_model:
|
||||
raise ValueError("GGUF quantization requires quantization_config.gguf_model")
|
||||
|
||||
# New API: DiffusionGGUFConfig (QuantizationConfig subclass)
|
||||
from vllm_omni.quantization.gguf_config import DiffusionGGUFConfig
|
||||
|
||||
if isinstance(quant_config, DiffusionGGUFConfig):
|
||||
if quant_config.gguf_model is None:
|
||||
raise ValueError("GGUF quantization requires gguf_model")
|
||||
return True
|
||||
|
||||
# Normal path: DiffusionQuantizationConfig
|
||||
if not hasattr(quant_config, "get_name"):
|
||||
# Fallback: if it carries gguf_model, treat as GGUF
|
||||
gguf_model = getattr(quant_config, "gguf_model", None)
|
||||
return bool(gguf_model)
|
||||
is_gguf = quant_config.get_name() == "gguf"
|
||||
if not is_gguf:
|
||||
# Dict-style config: {"method": "gguf", "gguf_model": "..."}
|
||||
if isinstance(quant_config, dict):
|
||||
if quant_config.get("method") == "gguf":
|
||||
if not quant_config.get("gguf_model"):
|
||||
raise ValueError("GGUF quantization requires gguf_model")
|
||||
return True
|
||||
return False
|
||||
gguf_model = getattr(quant_config, "gguf_model", None)
|
||||
if gguf_model is None:
|
||||
raise ValueError("GGUF quantization requires quantization_config.gguf_model")
|
||||
return True
|
||||
|
||||
# Check by name for any config that reports as "gguf"
|
||||
if hasattr(quant_config, "get_name") and quant_config.get_name() == "gguf":
|
||||
gguf_model = getattr(quant_config, "gguf_model", None)
|
||||
if gguf_model is None:
|
||||
raise ValueError("GGUF quantization requires gguf_model")
|
||||
return True
|
||||
|
||||
# Fallback: object with gguf_model attribute but no get_name
|
||||
if hasattr(quant_config, "gguf_model") and quant_config.gguf_model:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _is_transformer_source(self, source: "ComponentSource") -> bool:
|
||||
if source.subfolder == "transformer":
|
||||
|
||||
Reference in new issue
Block a user