Skip to content

Conversation

@GavChap
Copy link

@GavChap GavChap commented Oct 17, 2025

Updates only the ComfyUI package to support Qwen Loras without updating nunchaku version from 1.0.0.

Gives the following new nodes:

  • Lora loader
  • Lora Stacker (up to 6 loras)

These may be daisy-chained in order to load more.

Built upon the work of:
nunchaku-tech/nunchaku#680
and
nunchaku-tech/nunchaku#754

In my tests this loads almost all the loras I've tried with the correct weighting so images come out very well.

Issues known:

  • Unloads loras between runs to allow for chaining KSamplers.
  • Doesn't work with compile
  • Doesn't work with cpu offloading

@zhangyi90825-tech
Copy link

@GavChap How can I install it? Can you provide a tutorial

@kajfblsdkgnlsndg
Copy link

Looking forward to the official release of the merger

@GavChap
Copy link
Author

GavChap commented Oct 18, 2025

@GavChap How can I install it? Can you provide a tutorial

It's way easier on Linux than windows, but the general gist is:

In the current custom_nodes/ComfyUI-nunchaku directory run these commands

git fetch origin pull/665/head:pr-665
git checkout pr-665

If you already have the nunchaku comfyui nodes installed, otherwise the easiest way is download the source .zip

https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip

and unzip that into a directory into ComfyUI/custom_nodes/ComfyUI-nunchaku (though it doesn't really matter what directory name, you just have to make sure it's a sub directory of custom_nodes)

Then run pip install -r requirements.txt

You also need to have the latest release (1.0.0) of Nunchaku installed via a wheel as you would for getting Qwen running anyway.

@zhangyi90825-tech
Copy link

@GavChap我该如何安装?你能提供一下教程吗?

在 Linux 上比在 Windows 上更容易,但总体要点是:

在当前custom_nodes/ComfyUI-nunchaku目录中运行以下命令

git fetch origin pull/665/head:pr-665 git checkout pr-665

如果您已经安装了 nunchaku comfyui 节点,否则最简单的方法是下载源 .zip

https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip

并将其解压到 ComfyUI/custom_nodes/ComfyUI-nunchaku 目录中(虽然目录名称并不重要,但你只需要确保它是 custom_nodes 的子目录)

然后运行pip install -r requirements.txt

无论如何,您还需要通过轮子安装最新版本 (1.0.0) 的 Nunchaku,就像运行 Qwen 一样。

I am using version 1.0.1, but calling Lora does not work

@zhangyi90825-tech
Copy link

@GavChap我安装了吗?你能提供一些教程吗?

在 Linux 上比在 Windows 上更容易,但总体要点是:
在当前custom_nodes/ComfyUI-nunchaku目录中运行以下命令
git fetch origin pull/665/head:pr-665 git checkout pr-665
如果您已经安装了 nunchaku comfyui 节点,否则最简单的方法是下载源 .zip
https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip
把它的解压到 ComfyUI/custom_nodes/ComfyUI-nunchaku 目录中(虽然目录名称并不重要,但你只需要确保它是 custom_nodes 的子目录)
然后运行pip install -r requirements.txt
无论如何,您还需要通过轮子安装最新版本 (1.0.0) 的双节棍,就像运行 Qwen 一样。

我使用的是 1.0.1 版本,但是无法调用 Lora

I tried multiple Loras, but the generated images still have the same effect as Qwen Image

@GavChap
Copy link
Author

GavChap commented Oct 19, 2025

@GavChap我安装了吗?你能提供一些教程吗?

在 Linux 上比在 Windows 上更容易,但总体要点是:
在当前custom_nodes/ComfyUI-nunchaku目录中运行以下命令
git fetch origin pull/665/head:pr-665 git checkout pr-665
如果您已经安装了 nunchaku comfyui 节点,否则最简单的方法是下载源 .zip
https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip
把它的解压到 ComfyUI/custom_nodes/ComfyUI-nunchaku 目录中(虽然目录名称并不重要,但你只需要确保它是 custom_nodes 的子目录)
然后运行pip install -r requirements.txt
无论如何,您还需要通过轮子安装最新版本 (1.0.0) 的双节棍,就像运行 Qwen 一样。

我使用的是 1.0.1 版本,但是无法调用 Lora

I tried multiple Loras, but the generated images still have the same effect as Qwen Image

It should log to the ComfyUI log any errors it has loading loras. Can you link to one that doesn't work? I've tested it with Lightning loras and several realism loras and they all seem to work fine.

@GavChap
Copy link
Author

GavChap commented Oct 19, 2025

**zhangyi90825-tech ** commented

@zhangyi90825-tech I believe I've now fixed it, please do another pull to update it.

@zhangyi90825-tech
Copy link

zhangyi90825-tech commented Oct 20, 2025

** zhangyi90825-tech ** 评论道

@zhangyi90825-tech我相信我现在已经修复了它,请再次拉取以更新它。

thank! I am already using it and the effect is very good But there are several bugs, 1. After switching Lora multiple times, the graphics memory will be overloaded, causing the graphics card driver to restart. 2. When using Nunkaku Qwen Image and switching back to Nunkaku Flux to generate images, it will crash
Uploading ComfyUI_00021_.png…

@MarkShark2
Copy link

MarkShark2 commented Oct 20, 2025

Works pretty good for me and loads most keys, but it did not work when I had CPU offloading enabled. I got this error:

RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 1

Gemini managed to fix this issue by disabling and re-enabling the offloader in the forward function of the ComfyQwenImageWrapper class of wrappers/qwenimage.py like so:

    # Check if the LoRA stack has been changed by a loader node
    if self._applied_loras != self.loras:
        # The compose function handles resetting before applying the new stack
        reset_lora_v2(self.model)
        self._applied_loras = self.loras.copy()
        compose_loras_v2(self.model, self.loras)

        # BUG FIX v2: Force a full teardown and rebuild of the OffloadManager
        # This ensures all old buffers are deallocated before creating new ones.
        if hasattr(self.model, "offload_manager") and self.model.offload_manager is not None:
            # Store the settings from the old manager before destroying it
            manager = self.model.offload_manager
            offload_settings = {
                "num_blocks_on_gpu": manager.num_blocks_on_gpu,
                "use_pin_memory": manager.use_pin_memory,
            }

            # Step 1: Completely disable and clear the old offloader
            self.model.set_offload(False)

            # Step 2: Re-enable offloading, forcing it to rebuild
            # with the new tensor shapes and the original settings.
            self.model.set_offload(True, **offload_settings)

And now it works great with CPU offloading. I don't know if this is the best solution, but it works for me.

@GavChap
Copy link
Author

GavChap commented Oct 20, 2025

@zhangyi90825-tech When it crashes, please paste the log from comfyui in here

@zhangyi90825-tech
Copy link

@zhangyi90825-tech当它崩溃时,请将 comfyui 的日志粘贴到这里

Okay! I will send it here next time

@GavChap
Copy link
Author

GavChap commented Oct 20, 2025

Works pretty good for me and loads most keys, but it did not work when I had CPU offloading enabled. I got this error:

RuntimeError: The size of tensor a (128) must match the size of tensor b (160) at non-singleton dimension 1

Gemini managed to fix this issue by disabling and re-enabling the offloader in the forward function of the ComfyQwenImageWrapper class of wrappers/qwenimage.py like so:

@MarkShark2 Thanks for that, I've included that fix.

@cazs521
Copy link

cazs521 commented Oct 20, 2025

'🔥 - 18 Nodes not included in prompt but is activated'
model weight dtype torch.bfloat16, manual cast: None
model_type FLUX
Disabling CPU offload
Total LoRAs in stack: 2
Requested to load NunchakuQwenImage
Composing 2 LoRAs...
Applied LoRA compositions to 480 modules.
Could not find/apply LoRA to 120 modules, showing first 5: ['transformer_blocks.0.img_mod.1', 'transformer_blocks.0.txt_mod.1', 'transformer_blocks.1.img_mod.1', 'transformer_blocks.1.txt_mod.1', 'transformer_blocks.10.img_mod.1']
loaded completely 4473.0 242.02829551696777 True
Prompt executed in 54.52 seconds

@cazs521
Copy link

cazs521 commented Oct 20, 2025

@GavChap This appeared for me

@GavChap
Copy link
Author

GavChap commented Oct 20, 2025

'🔥 - 18 Nodes not included in prompt but is activated' model weight dtype torch.bfloat16, manual cast: None model_type FLUX Disabling CPU offload Total LoRAs in stack: 2 Requested to load NunchakuQwenImage Composing 2 LoRAs... Applied LoRA compositions to 480 modules. Could not find/apply LoRA to 120 modules, showing first 5: ['transformer_blocks.0.img_mod.1', 'transformer_blocks.0.txt_mod.1', 'transformer_blocks.1.img_mod.1', 'transformer_blocks.1.txt_mod.1', 'transformer_blocks.10.img_mod.1'] loaded completely 4473.0 242.02829551696777 True Prompt executed in 54.52 seconds

Where it states "Could not find/apply LoRA to 120 modules" it doesn't seem to mean much as the lora is still applied to the right number of modules and the right weights. However I have noticed that it detects as model Flux, which is weird. I'll look in to that

@cazs521
Copy link

cazs521 commented Oct 20, 2025

Yes, the model is correctly loaded. I tested it, and it's roughly the same as the original version with LoRA.

@GavChap
Copy link
Author

GavChap commented Oct 20, 2025

Yes, the model is correctly loaded. I tested it, and it's roughly the same as the original version with LoRA.

It seems to be certain lora trainers that create layers that shouldn't be there, because some of mine trained with AI toolkit don't have any errors about layers and work perfectly.

@cazs521
Copy link

cazs521 commented Oct 20, 2025

You're right. I loaded two LoRAs: one is Lightning's acceleration LoRA, which runs perfectly, and the other one I downloaded randomly.

@GavChap
Copy link
Author

GavChap commented Oct 20, 2025

I have noticed that it detects as model Flux, which is weird. I'll look in to that

As an aside, apparently that's correct for ComfyUI, Qwen is a "Flux" model type.

@Firetheft
Copy link

Great to finally see a workable solution—thanks for your effort, and we hope Dr. Li can take some time to review it!
and a few fix:
Unloads loras between runs to allow for chaining KSamplers.

change

        # Check if the LoRA stack has been changed by a loader node
        if self._applied_loras != self.loras:
            # The compose function handles resetting before applying the new stack
            reset_lora_v2(self.model)
            self._applied_loras = self.loras.copy()
            compose_loras_v2(self.model, self.loras)

            # BUG FIX v2: Force a full teardown and rebuild of the OffloadManager
            # This ensures all old buffers are deallocated before creating new ones.
            if hasattr(self.model, "offload_manager") and self.model.offload_manager is not None:

to

        # Check if the LoRA stack has been changed by a loader node
        loras_changed = self._applied_loras != self.loras
        
        # Additional checks: check if the underlying model is "dirty" (lora applied),
        # But this wrapper instance expects it to be clean (the loras list is empty).
        # This handles state out-of-sync issues caused by model deepcopy.
        model_is_dirty = (
            not self.loras and # We expect no LoRA
            hasattr(self.model, "_lora_slots") and self.model._lora_slots # But the model actually has LoRA
        )

        if loras_changed or model_is_dirty:
            # The compose function handles resetting before applying the new stack
            reset_lora_v2(self.model)
            self._applied_loras = self.loras.copy()
            compose_loras_v2(self.model, self.loras)

            # BUG FIX v2: Force a full teardown and rebuild of the OffloadManager
            if hasattr(self.model, "offload_manager") and self.model.offload_manager is not None:

…ra are going to cause a VRAM allocation issue and add safety margin parameter.
@cazs521
Copy link

cazs521 commented Oct 21, 2025

@GavChap 【Applied LoRA compositions to 480 modules.
Could not find/apply LoRA to 120 modules, showing first 5: ['transformer_blocks.0.img_mod.1', 'transformer_blocks.0.txt_mod.1', 'transformer_blocks.1.img_mod.1', 'transformer_blocks.1.txt_mod.1', 'transformer_blocks.10.img_mod.1']】 Actually, there is still a problem. The layers that weren't loaded in this part cause the output images to be insufficiently stylized. By increasing the weight of the LoRA, the original stylization effect of LoRA can appear. For example, when I increased the LoRA weight from 1 to 1.5, it worked completely.

@GavChap
Copy link
Author

GavChap commented Oct 21, 2025

@GavChap 【Applied LoRA compositions to 480 modules. Could not find/apply LoRA to 120 modules, showing first 5: ['transformer_blocks.0.img_mod.1', 'transformer_blocks.0.txt_mod.1', 'transformer_blocks.1.img_mod.1', 'transformer_blocks.1.txt_mod.1', 'transformer_blocks.10.img_mod.1']】 Actually, there is still a problem. The layers that weren't loaded in this part cause the output images to be insufficiently stylized. By increasing the weight of the LoRA, the original stylization effect of LoRA can appear. For example, when I increased the LoRA weight from 1 to 1.5, it worked completely.

@cazs521 what lora is it? Can you link me to it?

@peter4431
Copy link

peter4431 commented Oct 21, 2025

@GavChap

An error will be reported when batch size > 1, and wrappers/qwenimage.py needs to be modified

-        timestep_float = timestep.item() if isinstance(timestep, torch.Tensor) else float(timestep)
+        if isinstance(timestep, torch.Tensor):
+            if timestep.numel() == 1:
+                timestep_float = timestep.item()
+            else:
+                timestep_float = timestep.flatten()[0].item()
+        else:
+            timestep_float = float(timestep)

@cazs521
Copy link

cazs521 commented Oct 21, 2025

@GavChap 【Applied LoRA compositions to 480 modules. Could not find/apply LoRA to 120 modules, showing first 5: ['transformer_blocks.0.img_mod.1', 'transformer_blocks.0.txt_mod.1', 'transformer_blocks.1.img_mod.1', 'transformer_blocks.1.txt_mod.1', 'transformer_blocks.10.img_mod.1']】 Actually, there is still a problem. The layers that weren't loaded in this part cause the output images to be insufficiently stylized. By increasing the weight of the LoRA, the original stylization effect of LoRA can appear. For example, when I increased the LoRA weight from 1 to 1.5, it worked completely.

@cazs521 what lora is it? Can you link me to it?

The insufficient image style is due to the lack of steps, CFG, and accelerated models.

@defensezone
Copy link

@GavChap How can I install it? Can you provide a tutorial

It's way easier on Linux than windows, but the general gist is:

In the current custom_nodes/ComfyUI-nunchaku directory run these commands

git fetch origin pull/665/head:pr-665 git checkout pr-665

If you already have the nunchaku comfyui nodes installed, otherwise the easiest way is download the source .zip

https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip

and unzip that into a directory into ComfyUI/custom_nodes/ComfyUI-nunchaku (though it doesn't really matter what directory name, you just have to make sure it's a sub directory of custom_nodes)

Then run pip install -r requirements.txt

You also need to have the latest release (1.0.0) of Nunchaku installed via a wheel as you would for getting Qwen running anyway.

I'm getting this error when trying to load a LoRA for Qwen using the Nunchaku FLUX LoRA Loader node.

`ot prompt
!!! Exception during processing !!!
Traceback (most recent call last):
File "W:\GIT\ComfyUI\execution.py", line 496, in execute
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\GIT\ComfyUI\execution.py", line 315, in get_output_data
return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\GIT\ComfyUI\execution.py", line 289, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "W:\GIT\ComfyUI\execution.py", line 277, in process_inputs
result = f(**inputs)
^^^^^^^^^^^
File "W:\GIT\ComfyUI\custom_nodes\ComfyUI-nunchaku\nodes\lora\flux.py", line 114, in load_lora
assert isinstance(model_wrapper, ComfyFluxWrapper)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Prompt executed in 8.72 seconds`

@GavChap
Copy link
Author

GavChap commented Oct 24, 2025

@GavChap How can I install it? Can you provide a tutorial

It's way easier on Linux than windows, but the general gist is:
In the current custom_nodes/ComfyUI-nunchaku directory run these commands
git fetch origin pull/665/head:pr-665 git checkout pr-665
If you already have the nunchaku comfyui nodes installed, otherwise the easiest way is download the source .zip
https://github.com/GavChap/ComfyUI-nunchaku/archive/refs/heads/qwen-lora-suport-standalone.zip
and unzip that into a directory into ComfyUI/custom_nodes/ComfyUI-nunchaku (though it doesn't really matter what directory name, you just have to make sure it's a sub directory of custom_nodes)
Then run pip install -r requirements.txt
You also need to have the latest release (1.0.0) of Nunchaku installed via a wheel as you would for getting Qwen running anyway.

I'm getting this error when trying to load a LoRA for Qwen using the Nunchaku FLUX LoRA Loader node.

`ot prompt !!! Exception during processing !!! Traceback (most recent call last): File "W:\GIT\ComfyUI\execution.py", line 496, in execute output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\GIT\ComfyUI\execution.py", line 315, in get_output_data return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\GIT\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "W:\GIT\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "W:\GIT\ComfyUI\custom_nodes\ComfyUI-nunchaku\nodes\lora\flux.py", line 114, in load_lora assert isinstance(model_wrapper, ComfyFluxWrapper) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError

Prompt executed in 8.72 seconds`

Yes, because you need to use the new Nunchaku Qwen Lora Loader / Lora Stack instead.

@zhangyi90825-tech
Copy link

I have encountered a new problem again. When I use the Nvidia 3060 12G, I can generate images normally without using the Lora node. However, when I enable the Lora node, the error code is displayed The size of tensor a (32) must match the size of tensor b (96) at non-singleton dimension 1, May I ask how to solve this problem?
a61f69d67a655e55719c4685c8981258

@GavChap
Copy link
Author

GavChap commented Oct 31, 2025

I have encountered a new problem again. When I use the Nvidia 3060 12G, I can generate images normally without using the Lora node. However, when I enable the Lora node, the error code is displayed The size of tensor a (32) must match the size of tensor b (96) at non-singleton dimension 1, May I ask how to solve this problem? a61f69d67a655e55719c4685c8981258

@zhangyi90825-tech Can you link me to the lora so I can test? Also if you can upload an image with your workflow (with the node disabled) that'd help, also I think you're on an older version, as your dit loader doesn't have the extra field for vram auto-switching to cpu offload

@zhangyi90825-tech
Copy link

我又遇到了一个新问题。使用 Nvidia 3060 12G 显卡时,不使用 LoRa 节点可以正常生成图像。但是,启用 LoRa 节点后,会显示错误代码“张量 a (32) 的大小必须与张量 b (96) 的大小在非单例维度 1 处匹配”。请问如何解决这个问题?a61f69d67a655e55719c4685c8981258

@zhangyi90825-tech 另外,如果你能上传一张包含你的工作流程图觉得分区)的图片那就更好了。还有,我用你的版本比较旧,因为你的Dit Loader没有用于VRAM自动切换到CPU卸载的额外字段。

thank! After I update the new version, I can use it

@C00reNUT
Copy link

C00reNUT commented Nov 1, 2025

https://github.com/ussoewwin/ComfyUI-QwenImageLoraLoader is also an alternative

@zhangyi90825-tech
Copy link

救命,又出问题了,我不知道原因在哪里。
099cbf1aa92e0dd73c59248acec90098

@zhangyi90825-tech
Copy link

救命,又出问题了,我不知道原因在哪里。 099cbf1aa92e0dd73c59248acec90098

I encountered an error when updating today's version, but if I switch back to the previous version now, there will be no problem

@GavChap GavChap force-pushed the qwen-lora-suport-standalone branch from 83c670a to e45f9b6 Compare November 3, 2025 15:08
# Conflicts:
#	__init__.py
#	nodes/models/flux.py
#	nodes/models/qwenimage.py
@juntaosun
Copy link

juntaosun commented Nov 10, 2025

image

This image depicts an elegant Asian woman in a red suit, with fair skin. She is on the right side of the frame, leaning slightly forward, smiling as she hands a gold gift box tied with a red ribbon to another person. The box is inscribed with "Nunchaku." She wears a pearl necklace and delicate earrings, her golden curls cascading down her shoulders, exuding a noble air. Beside her lies a black Hermès handbag with a gold clasp, hinting at luxury and taste. The soft lighting and dim background highlight the woman and the gift, creating a warm, romantic, or celebratory atmosphere.

Haoming02 added a commit to Haoming02/sd-webui-forge-classic that referenced this pull request Nov 12, 2025
@Soliver84
Copy link

RAM and dimension FIX:
comfyanonymous/ComfyUI#10802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.