mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
SDNQ show a warining for no Triton instead and stop overriding matmul to false
This commit is contained in:
@@ -98,11 +98,6 @@ def create_sdnq_config(kwargs = None, allow: bool = True, module: str = 'Model',
|
||||
from modules import shared
|
||||
if allow and (shared.opts.sdnq_quantize_mode in {'pre', 'auto'}) and (module == 'any' or module in shared.opts.sdnq_quantize_weights):
|
||||
from modules.sdnq import SDNQConfig
|
||||
from modules.sdnq.common import use_torch_compile as sdnq_use_torch_compile
|
||||
|
||||
if shared.opts.sdnq_use_quantized_matmul and not sdnq_use_torch_compile:
|
||||
log.warning('SDNQ Quantized MatMul requires a working Triton install. Disabling Quantized MatMul.')
|
||||
shared.opts.sdnq_use_quantized_matmul = False
|
||||
|
||||
if weights_dtype is None:
|
||||
if module in {"TE", "LLM"} and shared.opts.sdnq_quantize_weights_mode_te not in {"Same as model", "default"}:
|
||||
@@ -354,7 +349,6 @@ def sdnq_quantize_model(model, op=None, sd_model=None, do_gc: bool = True, weigh
|
||||
global quant_last_model_name, quant_last_model_device # pylint: disable=global-statement
|
||||
from modules import devices, shared, timer
|
||||
from modules.sdnq import sdnq_post_load_quant
|
||||
from modules.sdnq.common import use_torch_compile as sdnq_use_torch_compile
|
||||
|
||||
if (
|
||||
hasattr(model, "quantization_config")
|
||||
@@ -364,10 +358,6 @@ def sdnq_quantize_model(model, op=None, sd_model=None, do_gc: bool = True, weigh
|
||||
log.warning(f'Quantization: Trying to quantize a pre-quantized model. Skipping quantization of module="{op if op is not None else model.__class__}"')
|
||||
return model
|
||||
|
||||
if shared.opts.sdnq_use_quantized_matmul and not sdnq_use_torch_compile:
|
||||
log.warning('SDNQ Quantized MatMul requires a working Triton install. Disabling Quantized MatMul.')
|
||||
shared.opts.sdnq_use_quantized_matmul = False
|
||||
|
||||
if weights_dtype is None:
|
||||
if (op is not None) and ("text_encoder" in op or op in {"TE", "LLM"}) and (shared.opts.sdnq_quantize_weights_mode_te not in {"Same as model", "default"}):
|
||||
weights_dtype = shared.opts.sdnq_quantize_weights_mode_te
|
||||
|
||||
@@ -191,10 +191,6 @@ def set_diffuser_options(sd_model, vae=None, op:str='model', offload:bool=True,
|
||||
for module_name in get_module_names(sd_model):
|
||||
module = getattr(sd_model, module_name, None)
|
||||
if hasattr(module, "quantization_config") and getattr(module.quantization_config, "quant_method", None) == "sdnq":
|
||||
from modules.sdnq.common import use_torch_compile as sdnq_use_torch_compile
|
||||
if shared.opts.sdnq_use_quantized_matmul and not sdnq_use_torch_compile:
|
||||
log.warning('SDNQ Quantized MatMul requires a working Triton install. Disabling Quantized MatMul.')
|
||||
shared.opts.sdnq_use_quantized_matmul = False
|
||||
if module.quantization_config.use_quantized_matmul != shared.opts.sdnq_use_quantized_matmul:
|
||||
from modules.sdnq.loader import apply_sdnq_options_to_model
|
||||
# log.debug(f'Setting {op} {module_name}: sdnq_use_quantized_matmul={shared.opts.sdnq_use_quantized_matmul}')
|
||||
|
||||
@@ -6,7 +6,7 @@ import torch
|
||||
|
||||
from modules import shared, devices
|
||||
|
||||
sdnq_version = "0.2.0"
|
||||
sdnq_version = "0.2.1"
|
||||
sdnq_keys = {"weight", "scale", "zero_point", "svd_up", "svd_down"}
|
||||
|
||||
torch_version = torch.__version__[:4]
|
||||
|
||||
@@ -3,6 +3,7 @@ import json
|
||||
import torch
|
||||
from diffusers.models.modeling_utils import ModelMixin
|
||||
|
||||
from modules import shared
|
||||
from .common import dtype_dict, is_fp8_mm_supported, use_tensorwise_fp8_matmul, check_torch_compile, linear_types
|
||||
from .quantizer import QuantizationMethod, SDNQConfig, SDNQQuantizer, sdnq_post_load_quant
|
||||
from .quant_utils import prepare_weight_for_matmul, prepare_svd_for_matmul
|
||||
@@ -288,7 +289,7 @@ def apply_sdnq_options_to_module(model, quantization_config: SDNQConfig, dtype:
|
||||
|
||||
def apply_sdnq_options_to_model(model, dtype: torch.dtype | None = None, dequantize_fp32: bool | None = None, use_quantized_matmul: bool | None = None):
|
||||
if use_quantized_matmul and not check_torch_compile():
|
||||
raise RuntimeError("SDNQ Quantized MatMul requires a working Triton install.")
|
||||
shared.log.warning("SDNQ: Quantized MatMul requires a working Triton install for best performance.")
|
||||
model = apply_sdnq_options_to_module(model, model.quantization_config, dtype=dtype, dequantize_fp32=dequantize_fp32, use_quantized_matmul=use_quantized_matmul)
|
||||
if hasattr(model, "quantization_config"):
|
||||
if use_quantized_matmul is not None:
|
||||
|
||||
@@ -920,7 +920,7 @@ class SDNQConfig(QuantizationConfigMixin):
|
||||
Safety checker that arguments are correct
|
||||
"""
|
||||
if self.use_quantized_matmul and not check_torch_compile():
|
||||
raise RuntimeError("SDNQ Quantized MatMul requires a working Triton install.")
|
||||
shared.log.warning("SDNQ: Quantized MatMul requires a working Triton install for best performance.")
|
||||
if self.weights_dtype not in accepted_weight_dtypes:
|
||||
raise ValueError(f"SDNQ only support weight dtypes in {accepted_weight_dtypes} but found {self.weights_dtype}")
|
||||
if self.quantized_matmul_dtype is not None and self.quantized_matmul_dtype not in accepted_matmul_dtypes:
|
||||
|
||||
Reference in New Issue
Block a user