mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Use inference_context with SDNQ
This commit is contained in:
@@ -14,6 +14,7 @@ from .dequantizer import dequantizer_dict
|
||||
from .forward import get_forward_func
|
||||
|
||||
|
||||
@devices.inference_context()
|
||||
def sdnq_quantize_layer(layer, weights_dtype="int8", torch_dtype=None, group_size=0, quant_conv=False, use_quantized_matmul=False, use_quantized_matmul_conv=False, dequantize_fp32=False, quantization_device=None, return_device=None, param_name=None): # pylint: disable=unused-argument
|
||||
layer_class_name = layer.__class__.__name__
|
||||
if layer_class_name in allowed_types:
|
||||
@@ -262,7 +263,8 @@ class SDNQQuantizer(DiffusersQuantizer):
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
param_value.data = param_value.clone() # safetensors is unable to release the cpu memory without this
|
||||
with devices.inference_context():
|
||||
param_value.data = param_value.clone() # safetensors is unable to release the cpu memory without this
|
||||
return False
|
||||
|
||||
def check_quantized_param(self, *args, **kwargs) -> bool:
|
||||
@@ -271,6 +273,7 @@ class SDNQQuantizer(DiffusersQuantizer):
|
||||
"""
|
||||
return self.check_if_quantized_param(*args, **kwargs)
|
||||
|
||||
@devices.inference_context()
|
||||
def create_quantized_param( # pylint: disable=arguments-differ
|
||||
self,
|
||||
model,
|
||||
|
||||
Reference in New Issue
Block a user