diff --git a/utils.py b/utils.py index ea4bc50..b7f76e6 100644 --- a/utils.py +++ b/utils.py @@ -73,7 +73,10 @@ def apply_lora(model, device_to, transformer_load_device, params_to_keep=None, d set_module_tensor_to_device(model.model.diffusion_model, key, device=transformer_load_device, dtype=dtype_to_use, value=state_dict[key]) except: continue - model.patch_weight_to_device("{}.{}".format(name, param), device_to=device_to) + if low_mem_load: + model.patch_weight_to_device("{}.{}".format(name, param), device_to=device_to, inplace_update=True) + else: + model.patch_weight_to_device("{}.{}".format(name, param), device_to=device_to) if low_mem_load: try: set_module_tensor_to_device(model.model.diffusion_model, key, device=transformer_load_device, dtype=dtype_to_use, value=model.model.diffusion_model.state_dict()[key]) @@ -232,4 +235,4 @@ def fourier_filter(x, scale_low=1.0, scale_high=1.5, freq_cutoff=20): # 5) Restore original dtype x_filtered = x_filtered.to(dtype) - return x_filtered \ No newline at end of file + return x_filtered