SDNQ disable fp8 mm with pre-quants on unsupported gpus

This commit is contained in:
Disty0
2026-04-15 23:12:46 +03:00
parent 94d378651e
commit 202f12ea6c
2 changed files with 17 additions and 2 deletions
+12 -1
View File
@@ -6,7 +6,7 @@ import torch
from modules import shared, devices
sdnq_version = "0.1.7"
sdnq_version = "0.1.8"
dtype_dict = {
### Integers
@@ -335,6 +335,17 @@ def check_torch_compile(): # dynamo can be disabled after startup
return use_torch_compile and not torch._dynamo.config.disable # pylint: disable=protected-access
if os.environ.get("SDNQ_ALLOW_FP8_MM", None) is None:
if devices.backend == "cuda":
is_fp8_mm_supported = bool(torch.cuda.get_device_capability(devices.device) >= (8,9))
elif devices.backend == "rocm":
gfx_version = devices.get_hip_agent().gfx_version
is_fp8_mm_supported = bool(gfx_version >= 0x1200 or (gfx_version >= 0x940 and gfx_version < 0x1000))
else:
is_fp8_mm_supported = False
else:
is_fp8_mm_supported = os.environ.get("SDNQ_ALLOW_FP8_MM", "0").lower() not in {"0", "false", "no"}
if os.environ.get("SDNQ_USE_TENSORWISE_FP8_MM", None) is None:
# row-wise FP8 only exist on H100 hardware, sdnq will use software row-wise with tensorwise hardware with this setting
use_tensorwise_fp8_matmul = bool(devices.backend != "cuda" or (devices.backend == "cuda" and torch.cuda.get_device_capability(devices.device) < (9,0)))
+5 -1
View File
@@ -3,7 +3,7 @@ import json
import torch
from diffusers.models.modeling_utils import ModelMixin
from .common import dtype_dict, use_tensorwise_fp8_matmul, check_torch_compile, conv_types, linear_types
from .common import dtype_dict, use_tensorwise_fp8_matmul, is_fp8_mm_supported, check_torch_compile, conv_types, linear_types
from .quantizer import SDNQConfig, sdnq_post_load_quant, prepare_weight_for_matmul, prepare_svd_for_matmul, get_quant_args_from_config
from .forward import get_forward_func
from .file_loader import load_files
@@ -172,6 +172,10 @@ def apply_sdnq_options_to_module(model, dtype: torch.dtype | None = None, dequan
if hasattr(module, "sdnq_dequantizer"):
layer_class_name = module.original_class.__name__
current_use_quantized_matmul = use_quantized_matmul
if not is_fp8_mm_supported and module.sdnq_dequantizer.quantized_matmul_dtype in {"fp8", "float8_e4m3fn"}:
current_use_quantized_matmul = False
if current_use_quantized_matmul:
if layer_class_name in conv_types:
output_channel_size, channel_size = module.sdnq_dequantizer.original_shape[:2]