add teacache

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-04-05 20:15:48 -04:00
parent fcde9f406d
commit 228da75a2e
15 changed files with 524 additions and 132 deletions
+16
View File
@@ -0,0 +1,16 @@
import diffusers
from modules import shared
def apply_teacache_patch(cls):
if shared.opts.teacache_enabled:
from modules import teacache
shared.log.debug(f'Transformers cache: type=teacache patch=forward cls={cls.__name__}')
if cls.__name__ == 'LTXVideoTransformer3DModel':
cls.forward = teacache.teacache_ltx_forward
elif cls.__name__ == 'MochiTransformer3DModel':
cls.forward = teacache.teacache_mochi_forward
elif cls.__name__ == 'CogVideoXTransformer3DModel':
cls.forward = teacache.teacache_cog_forward
diffusers.FluxTransformer2DModel.forward = teacache.teacache_flux_forward