Better propagation fix

#163
This commit is contained in:
City
2024-12-14 00:38:11 +01:00
parent 23b9817081
commit 65a7c895bb
+12 -3
View File
@@ -119,7 +119,10 @@ class GGMLLayer(torch.nn.Module):
# dequantize tensor while patches load
weight = dequantize_tensor(tensor, dtype, self.dequant_dtype)
weight.__class__ = torch.Tensor # prevent propagating custom tensor class
# prevent propagating custom tensor class
if isinstance(weight, GGMLTensor):
weight.__class__ = torch.Tensor
# apply patches
if patch_list:
@@ -152,8 +155,14 @@ class GGMLLayer(torch.nn.Module):
def forward_comfy_cast_weights(self, input, *args, **kwargs):
if self.is_ggml_quantized():
return self.forward_ggml_cast_weights(input, *args, **kwargs)
return super().forward_comfy_cast_weights(input, *args, **kwargs)
out = self.forward_ggml_cast_weights(input, *args, **kwargs)
else:
out = super().forward_comfy_cast_weights(input, *args, **kwargs)
# non-ggml forward might still propagate custom tensor class
if isinstance(out, GGMLTensor):
out.__class__ = torch.Tensor
return out
def forward_ggml_cast_weights(self, input):
raise NotImplementedError