From cf716e1c979ca5fadedd6490e338e2edd9f1aab4 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 15 May 2025 22:51:35 +0300 Subject: [PATCH] NNCF fix CogVideo --- modules/model_quant_nncf.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/model_quant_nncf.py b/modules/model_quant_nncf.py index 361acf789..9e8818330 100644 --- a/modules/model_quant_nncf.py +++ b/modules/model_quant_nncf.py @@ -228,6 +228,12 @@ class NNCFQuantizer(DiffusersQuantizer): layer, tensor_name = get_module_from_name(model, param_name) layer._parameters[tensor_name] = torch.nn.Parameter(param_value).to(device=target_device) # pylint: disable=protected-access + # nncf_padding_value somehow ends up in the meta device with cogvideo even if we don't use init_empty_weights + # set it to the default value if it is in the meta device: + if layer.__class__.__name__ == "NNCFConv2d" and hasattr(layer, "get_padding_value_ref") and hasattr(layer, "_set_padding_value"): + if layer.get_padding_value_ref().device == torch.device("meta"): + layer._set_padding_value(torch.zeros([1])) + split_param_name = param_name.split(".") if param_name not in self.modules_to_not_convert and not any(param in split_param_name for param in self.modules_to_not_convert): layer = nncf_compress_layer(