Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Support loading flux 2 klein checkpoints saved with SaveCheckpoint. (#12033)

comfyanonymous09a2e67151c6
diff --git a/comfy/supported_models.py b/comfy/supported_models.py
index 70abebf46..45d913fa6 100644
--- a/comfy/supported_models.py
+++ b/comfy/supported_models.py
@@ -771,10 +771,24 @@ class Flux2(Flux):
return out
def clip_target(self, state_dict={}):
- return None # TODO
pref = self.text_encoder_key_prefix[0]
- t5_detect = comfy.text_encoders.sd3_clip.t5_xxl_detect(state_dict, "{}t5xxl.transformer.".format(pref))
- return supported_models_base.ClipTarget(comfy.text_encoders.flux.FluxTokenizer, comfy.text_encoders.flux.flux_clip(**t5_detect))
+ detect = comfy.text_encoders.hunyuan_video.llama_detect(state_dict, "{}qwen3_4b.transformer.".format(pref))
+ if len(detect) > 0:
+ detect["model_type"] = "qwen3_4b"
+ return supported_models_base.ClipTarget(comfy.text_encoders.flux.KleinTokenizer, comfy.text_encoders.flux.klein_te(**detect))
+
+ detect = comfy.text_encoders.hunyuan_video.llama_detect(state_dict, "{}qwen3_8b.transformer.".format(pref))
+ if len(detect) > 0:
+ detect["model_type"] = "qwen3_8b"
+ return supported_models_base.ClipTarget(comfy.text_encoders.flux.KleinTokenizer8B, comfy.text_encoders.flux.klein_te(**detect))
+
+ detect = comfy.text_encoders.hunyuan_video.llama_detect(state_dict, "{}mistral3_24b.transformer.".format(pref))
+ if len(detect) > 0:
+ if "{}mistral3_24b.transformer.model.layers.39.post_attention_layernorm.weight".format(pref) not in state_dict:
+ detect["pruned"] = True
+ return supported_models_base.ClipTarget(comfy.text_encoders.flux.Flux2Tokenizer, comfy.text_encoders.flux.flux2_te(**detect))
+
+ return None
class GenmoMochi(supported_models_base.BASE):
unet_config = {
diff --git a/comfy/text_encoders/hunyuan_video.py b/comfy/text_encoders/hunyuan_video.py
index a9a6c525e..2ddb4da60 100644
--- a/comfy/text_encoders/hunyuan_video.py
+++ b/comfy/text_encoders/hunyuan_video.py
@@ -10,9 +10,11 @@ import comfy.utils
def llama_detect(state_dict, prefix=""):
out = {}
- t5_key = "{}model.norm.weight".format(prefix)
- if t5_key in state_dict:
- out["dtype_llama"] = state_dict[t5_key].dtype
+ norm_keys = ["{}model.norm.weight".format(prefix), "{}model.layers.0.input_layernorm.weight".format(prefix)]
+ for norm_key in norm_keys:
+ if norm_key in state_dict:
+ out["dtype_llama"] = state_dict[norm_key].dtype
+ break
quant = comfy.utils.detect_layer_quantization(state_dict, prefix)
if quant is not None: