From 5d119f0532bdafe326bd6b41d52090f245404388 Mon Sep 17 00:00:00 2001 From: azazeal04 <132445160+azazeal04@users.noreply.github.com> Date: Sat, 4 Apr 2026 20:09:10 +0200 Subject: [PATCH] Implement allow_fp16 configuration in model detection Add logic to set allow_fp16 based on weight standard deviation --- comfy/model_detection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/comfy/model_detection.py b/comfy/model_detection.py index 7caad2e0b..e2bdb1e2d 100644 --- a/comfy/model_detection.py +++ b/comfy/model_detection.py @@ -73,6 +73,14 @@ def detect_unet_config(state_dict, key_prefix, metadata=None): dit_config["axes_lens"] = [1536, 512, 512] dit_config["rope_theta"] = 256.0 + try: + dit_config["allow_fp16"] = torch.std( + state_dict['{}layers.{}.ffn_norm1.weight'.format(key_prefix, dit_config["n_layers"] - 2)], + unbiased=False + ).item() < 0.42 + except Exception: + pass + if '{}cap_pad_token'.format(key_prefix) in state_dict_keys or '{}x_pad_token'.format(key_prefix) in state_dict_keys: dit_config["pad_tokens_multiple"] = 32