mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-07-20 00:47:01 +08:00
Merge branch 'comfyanonymous:master' into master
This commit is contained in:
commit
00609a5102
@ -236,10 +236,10 @@ class QwenImageTransformerBlock(nn.Module):
|
|||||||
img_mod1, img_mod2 = img_mod_params.chunk(2, dim=-1)
|
img_mod1, img_mod2 = img_mod_params.chunk(2, dim=-1)
|
||||||
txt_mod1, txt_mod2 = txt_mod_params.chunk(2, dim=-1)
|
txt_mod1, txt_mod2 = txt_mod_params.chunk(2, dim=-1)
|
||||||
|
|
||||||
img_normed = self.img_norm1(hidden_states)
|
img_modulated, img_gate1 = self._modulate(self.img_norm1(hidden_states), img_mod1)
|
||||||
img_modulated, img_gate1 = self._modulate(img_normed, img_mod1)
|
del img_mod1
|
||||||
txt_normed = self.txt_norm1(encoder_hidden_states)
|
txt_modulated, txt_gate1 = self._modulate(self.txt_norm1(encoder_hidden_states), txt_mod1)
|
||||||
txt_modulated, txt_gate1 = self._modulate(txt_normed, txt_mod1)
|
del txt_mod1
|
||||||
|
|
||||||
img_attn_output, txt_attn_output = self.attn(
|
img_attn_output, txt_attn_output = self.attn(
|
||||||
hidden_states=img_modulated,
|
hidden_states=img_modulated,
|
||||||
@ -248,16 +248,20 @@ class QwenImageTransformerBlock(nn.Module):
|
|||||||
image_rotary_emb=image_rotary_emb,
|
image_rotary_emb=image_rotary_emb,
|
||||||
transformer_options=transformer_options,
|
transformer_options=transformer_options,
|
||||||
)
|
)
|
||||||
|
del img_modulated
|
||||||
|
del txt_modulated
|
||||||
|
|
||||||
hidden_states = hidden_states + img_gate1 * img_attn_output
|
hidden_states = hidden_states + img_gate1 * img_attn_output
|
||||||
encoder_hidden_states = encoder_hidden_states + txt_gate1 * txt_attn_output
|
encoder_hidden_states = encoder_hidden_states + txt_gate1 * txt_attn_output
|
||||||
|
del img_attn_output
|
||||||
|
del txt_attn_output
|
||||||
|
del img_gate1
|
||||||
|
del txt_gate1
|
||||||
|
|
||||||
img_normed2 = self.img_norm2(hidden_states)
|
img_modulated2, img_gate2 = self._modulate(self.img_norm2(hidden_states), img_mod2)
|
||||||
img_modulated2, img_gate2 = self._modulate(img_normed2, img_mod2)
|
|
||||||
hidden_states = torch.addcmul(hidden_states, img_gate2, self.img_mlp(img_modulated2))
|
hidden_states = torch.addcmul(hidden_states, img_gate2, self.img_mlp(img_modulated2))
|
||||||
|
|
||||||
txt_normed2 = self.txt_norm2(encoder_hidden_states)
|
txt_modulated2, txt_gate2 = self._modulate(self.txt_norm2(encoder_hidden_states), txt_mod2)
|
||||||
txt_modulated2, txt_gate2 = self._modulate(txt_normed2, txt_mod2)
|
|
||||||
encoder_hidden_states = torch.addcmul(encoder_hidden_states, txt_gate2, self.txt_mlp(txt_modulated2))
|
encoder_hidden_states = torch.addcmul(encoder_hidden_states, txt_gate2, self.txt_mlp(txt_modulated2))
|
||||||
|
|
||||||
return encoder_hidden_states, hidden_states
|
return encoder_hidden_states, hidden_states
|
||||||
|
|||||||
@ -504,10 +504,7 @@ class LoadedModel:
|
|||||||
use_more_vram = lowvram_model_memory
|
use_more_vram = lowvram_model_memory
|
||||||
if use_more_vram == 0:
|
if use_more_vram == 0:
|
||||||
use_more_vram = 1e32
|
use_more_vram = 1e32
|
||||||
if use_more_vram > 0:
|
self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)
|
||||||
self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)
|
|
||||||
else:
|
|
||||||
self.model.partially_unload(self.model.offload_device, -use_more_vram, force_patch_weights=force_patch_weights)
|
|
||||||
|
|
||||||
real_model = self.model.model
|
real_model = self.model.model
|
||||||
|
|
||||||
|
|||||||
@ -928,6 +928,9 @@ class ModelPatcher:
|
|||||||
extra_memory += (used - self.model.model_loaded_weight_memory)
|
extra_memory += (used - self.model.model_loaded_weight_memory)
|
||||||
|
|
||||||
self.patch_model(load_weights=False)
|
self.patch_model(load_weights=False)
|
||||||
|
if extra_memory < 0 and not unpatch_weights:
|
||||||
|
self.partially_unload(self.offload_device, -extra_memory, force_patch_weights=force_patch_weights)
|
||||||
|
return 0
|
||||||
full_load = False
|
full_load = False
|
||||||
if self.model.model_lowvram == False and self.model.model_loaded_weight_memory > 0:
|
if self.model.model_lowvram == False and self.model.model_loaded_weight_memory > 0:
|
||||||
self.apply_hooks(self.forced_hooks, force_apply=True)
|
self.apply_hooks(self.forced_hooks, force_apply=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user