model_detection: deep clone pre edited edited weights (#12862)

Deep clone these weights as needed to avoid segfaulting when it tries
to touch the original mmap.
This commit is contained in:
rattus
2026-03-09 20:50:10 -07:00
committed by GitHub
parent c4fb0271cd
commit a912809c25

View File

@@ -1,4 +1,5 @@
import json
import comfy.memory_management
import comfy.supported_models
import comfy.supported_models_base
import comfy.utils
@@ -1118,8 +1119,13 @@ def convert_diffusers_mmdit(state_dict, output_prefix=""):
new[:old_weight.shape[0]] = old_weight
old_weight = new
if old_weight is out_sd.get(t[0], None) and comfy.memory_management.aimdo_enabled:
old_weight = old_weight.clone()
w = old_weight.narrow(offset[0], offset[1], offset[2])
else:
if comfy.memory_management.aimdo_enabled:
weight = weight.clone()
old_weight = weight
w = weight
w[:] = fun(weight)