mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-16 01:36:41 +08:00
Make Lumina2 compatible with EasyCache
This commit is contained in:
parent
401757acde
commit
7d9d473193
@ -11,6 +11,7 @@ import comfy.ldm.common_dit
|
|||||||
from comfy.ldm.modules.diffusionmodules.mmdit import TimestepEmbedder
|
from comfy.ldm.modules.diffusionmodules.mmdit import TimestepEmbedder
|
||||||
from comfy.ldm.modules.attention import optimized_attention_masked
|
from comfy.ldm.modules.attention import optimized_attention_masked
|
||||||
from comfy.ldm.flux.layers import EmbedND
|
from comfy.ldm.flux.layers import EmbedND
|
||||||
|
import comfy.patcher_extension
|
||||||
|
|
||||||
|
|
||||||
def modulate(x, scale):
|
def modulate(x, scale):
|
||||||
@ -590,8 +591,15 @@ class NextDiT(nn.Module):
|
|||||||
|
|
||||||
return padded_full_embed, mask, img_sizes, l_effective_cap_len, freqs_cis
|
return padded_full_embed, mask, img_sizes, l_effective_cap_len, freqs_cis
|
||||||
|
|
||||||
# def forward(self, x, t, cap_feats, cap_mask):
|
|
||||||
def forward(self, x, timesteps, context, num_tokens, attention_mask=None, **kwargs):
|
def forward(self, x, timesteps, context, num_tokens, attention_mask=None, **kwargs):
|
||||||
|
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
|
||||||
|
self._forward,
|
||||||
|
self,
|
||||||
|
comfy.patcher_extension.get_all_wrappers(comfy.patcher_extension.WrappersMP.DIFFUSION_MODEL, kwargs.get("transformer_options", {}))
|
||||||
|
).execute(x, timesteps, context, num_tokens, attention_mask, **kwargs)
|
||||||
|
|
||||||
|
# def forward(self, x, t, cap_feats, cap_mask):
|
||||||
|
def _forward(self, x, timesteps, context, num_tokens, attention_mask=None, **kwargs):
|
||||||
t = 1.0 - timesteps
|
t = 1.0 - timesteps
|
||||||
cap_feats = context
|
cap_feats = context
|
||||||
cap_mask = attention_mask
|
cap_mask = attention_mask
|
||||||
|
|||||||
@ -13,6 +13,8 @@ def easycache_forward_wrapper(executor, *args, **kwargs):
|
|||||||
# get values from args
|
# get values from args
|
||||||
x: torch.Tensor = args[0]
|
x: torch.Tensor = args[0]
|
||||||
transformer_options: dict[str] = args[-1]
|
transformer_options: dict[str] = args[-1]
|
||||||
|
if not isinstance(transformer_options, dict):
|
||||||
|
transformer_options = kwargs.get("transformer_options")
|
||||||
easycache: EasyCacheHolder = transformer_options["easycache"]
|
easycache: EasyCacheHolder = transformer_options["easycache"]
|
||||||
sigmas = transformer_options["sigmas"]
|
sigmas = transformer_options["sigmas"]
|
||||||
uuids = transformer_options["uuids"]
|
uuids = transformer_options["uuids"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user