Skip to content

Commit a912809

Browse files
authored
model_detection: deep clone pre edited edited weights (Comfy-Org#12862)
Deep clone these weights as needed to avoid segfaulting when it tries to touch the original mmap.
1 parent c4fb027 commit a912809

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

comfy/model_detection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import comfy.memory_management
23
import comfy.supported_models
34
import comfy.supported_models_base
45
import comfy.utils
@@ -1118,8 +1119,13 @@ def convert_diffusers_mmdit(state_dict, output_prefix=""):
11181119
new[:old_weight.shape[0]] = old_weight
11191120
old_weight = new
11201121

1122+
if old_weight is out_sd.get(t[0], None) and comfy.memory_management.aimdo_enabled:
1123+
old_weight = old_weight.clone()
1124+
11211125
w = old_weight.narrow(offset[0], offset[1], offset[2])
11221126
else:
1127+
if comfy.memory_management.aimdo_enabled:
1128+
weight = weight.clone()
11231129
old_weight = weight
11241130
w = weight
11251131
w[:] = fun(weight)

0 commit comments

Comments
 (0)