From 438595b78b15bb395d26eb6012702627f4ab1a1d Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Thu, 15 Oct 2026 09:56:40 -0600 Subject: [PATCH] Fixed issue with caching text embeddings on Flux.3 Image --- extensions_built_in/diffusion_models/flux3/flux3.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions_built_in/diffusion_models/flux3/flux3.py b/extensions_built_in/diffusion_models/flux3/flux3.py index 42e59d3..71efd16 100644 --- a/extensions_built_in/diffusion_models/flux3/flux3.py +++ b/extensions_built_in/diffusion_models/flux3/flux3.py @@ -48,6 +48,7 @@ from toolkit.config_modules import GenerateImageConfig, ModelConfig from toolkit.metadata import get_meta_for_safetensors from toolkit.models.base_model import BaseModel from toolkit.paths import MODELS_PATH +from toolkit.unloader import FakeTextEncoder from toolkit.samplers.custom_flowmatch_sampler import ( CustomFlowMatchEulerDiscreteScheduler, ) @@ -367,8 +368,14 @@ class Flux3Model(BaseModel): # cond and uncond were encoded separately, so their pad-to-80 windows # can differ. The DiT attends to real pad-token states, not zeros, so - # re-encode the shorter prompt at the longer window when the TE is up. - if unconditional_embeds is not None and self.text_encoder is not None: + # re-encode the shorter prompt at the longer window when the TE is up + # (cached embeddings: the TE is an unloaded stub; the shorter side is + # zero-padded in build_text_conditioning instead) + if ( + unconditional_embeds is not None + and self.text_encoder is not None + and not isinstance(self.text_encoder, FakeTextEncoder) + ): cond_len = conditional_embeds.text_embeds[0].shape[0] uncond_len = unconditional_embeds.text_embeds[0].shape[0] if cond_len != uncond_len: