shiimizu / ComfyUI_smZNodes

Custom nodes for ComfyUI such as CLIP Text Encode++
GNU General Public License v3.0
200 stars 14 forks source link

CLIP Text Encode node no longer works with FP8 after the latest update #89

Closed LuLmaster69 closed 2 weeks ago

LuLmaster69 commented 1 month ago

I update every few days.

After updating my nodes I've noticed that CLIP Text Encode node no longer works when launching ComfyUI in FP8 mode

_Error occurred when executing smZ CLIPTextEncode:

tuple index out of range

File "D:\SD\ai\ComfyUI\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\nodes.py", line 87, in encode result = run(params) ^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 755, in run cond, pooled = clip_clone.encode_from_tokens(tokens, True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\comfy\sd.py", line 116, in encode_from_tokens o = self.cond_stage_model.encode_token_weights(tokens) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 489, in encode_token_weights g_out, g_pooled = self.clip_g.encode_token_weights(token_weight_pairs_g, steps, current_step, multi) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 443, in encode_token_weights if multi: schedules = prompt_parser.get_multicond_learned_conditioning(model_hijack.cond_stage_model, texts, steps, None, opts.use_old_scheduling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\modules\prompt_parser.py", line 270, in get_multicond_learned_conditioning learned_conditioning = get_learned_conditioning(model, prompt_flat_list, steps, hires_steps, use_old_scheduling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\modules\prompt_parser.py", line 198, in get_learned_conditioning conds = model.forward(texts) ^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\modules\sd_hijack_clip.py", line 224, in forward z = self.process_tokens(tokens, multipliers, multipliers_solo_emb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\modules\sd_hijack_clip.py", line 254, in process_tokens z = self.encode_with_transformers(tokens) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 197, in encode_with_transformers return self.encode_with_transformerscomfy(tokens, return_pooled) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 125, in encode_with_transformerscomfy z, pooled = ClipTextEncoderCustom._forward(self.wrapped, tokens_orig) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\custom_nodes\ComfyUI_smZNodes\smZNodes.py", line 114, in _forward z, pooled_output = self.forward(tokens) ^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\comfy\sd1_clip.py", line 181, in forward tokens = self.set_up_textual_embeddings(tokens, backup_embeds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\SD\ai\ComfyUI\ComfyUI\comfy\sd1_clip.py", line 153, in set_up_textual_embeddings if y.shape[0] == current_embeds.weight.shape[1]:

LuLmaster69 commented 1 month ago

Sorry, seems to be issue with my Comfy setup

bananasss00 commented 1 month ago

@LuLmaster69 same problem on latest smz update, how you fix?

PS: i am using fp8 mode too, in fp16 work

LuLmaster69 commented 1 month ago

@bananasss00 I am not sure if the problem is with smZNodes or with ComfyUI itself. To test this, I have downloaded fresh portable instance of ComfyUI and installed only smZNodes. The result is that nodes did not work in fp8 mode. However, the problem may be with ComfyUI itself, since other similar nodes also don't work in FP8, such as https://github.com/Extraltodeus/Vector_Sculptor_ComfyUI

JeffreyBull76 commented 2 weeks ago

Im having a similar problem, after updating Comfy my clip text encod++ only works when using the 'comfy' option, any other parser just outputs a black image but no error is displayed

LuLmaster69 commented 2 weeks ago

Im having a similar problem, after updating Comfy my clip text encod++ only works when using the 'comfy' option, any other parser just outputs a black image but no error is displayed

works on my end after the last update

JeffreyBull76 commented 2 weeks ago

I've attached various examples to aid in troubleshooting this. So this is a niche case as I use a particular workflow where I generate a low step count base gen, turn that back into noise and then put that back through a range of ksamplers. When using this node it works absolutely fine prior to the last update. After that it only works when selecting comfy++ as the parser in the smz clip-text-encode++ node.

See examples below


You can see leaving the base gen step count at 5 and the final step count at 25, it works fine using comfy++ parser PossibleBug1


when I select A111 it outputs black and base color failed generations (it does this for all parsers including fixed, full, compel etc) PossibleBug2


however bypassing this node and using a different parser (see examples) I can run the same parser (A111) and with the identical step count and settings and get a generation that works. PossibleBug4


If I up base gen step count to 25 it does generate images using this node and the non comfy++ parsers but they are notably washed and poor quality.

As an aside if I run this node on a more standard setup just denoising the base noise output it works fine so its something weird going on with renoising the output using that node.


I've included the json for the workflow in case you want to test it. Possible_Parser_Bug_Example.json

shiimizu commented 2 weeks ago

@JeffreyBull76 Thank you for the workflow! That's strange, because when I tried it, every parser worked. The only thing I changed was the vae to sdxl 1.0 and bypassing all the LoRAs.

JeffreyBull76 commented 1 week ago

OK It's a really weird one this. I tried a fresh install, this did improve things. There was definitely an issue in my old version despite being up to date. However I then began encountering this issue again in a similar form, it would throw this error when using those parsers

D:\SDInstalls\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py:359: RuntimeWarning: invalid value encountered in cast return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))

It turned out this was related to the use of square brackets in the prompt, when I removed those the error did not occur and it runs fine. Very strange as the square brackets worked before, but thought you'd like to have the update.