Better fix for the Transformer warning

Explicitly set the value of patch_model_to to the intended torch device obtained from get_torch_device. This fixes the Transformer warning.
Currently, it takes the current device of the model, which is cpu as the model is loaded in to cpu by deault.
This commit is contained in:
BVH 2024-04-15 13:25:20 +05:30 committed by GitHub
parent 4b1ed67327
commit d3eaae7f54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -286,7 +286,7 @@ class LoadedModel:
return self.model_memory()
def model_load(self, lowvram_model_memory=0):
patch_model_to = self.device
patch_model_to = get_torch_device()
self.model.model_patches_to(self.device)
self.model.model_patches_to(self.model.model_dtype())
@ -304,7 +304,7 @@ class LoadedModel:
raise e
if is_intel_xpu() and not args.disable_ipex_optimize:
self.real_model = torch.xpu.optimize(self.real_model.to("xpu").eval(), inplace=True, auto_kernel_selection=True, graph_mode=True)
self.real_model = torch.xpu.optimize(self.real_model.eval(), inplace=True, auto_kernel_selection=True, graph_mode=True)
self.weights_loaded = True
return self.real_model