From 96a0736b2f4427e1fdd4869654c34b0d005e2782 Mon Sep 17 00:00:00 2001 From: Enrico Date: Tue, 2 Dec 2025 14:43:26 +0100 Subject: [PATCH] 1.0.7 nunchaku qwen and tiled diffusion fixes. update readme , bump version --- README.md | 8 +++++++- nunchaku_compat.py | 40 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbe5003..fe7a3fe 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,13 @@ More examples: ## Changelog -**1.0.5** +**1.0.7** + +- nunchaku qwen patch fix, tiled diffusion patch fix + users reported issues with dimensions not being handled correctly, this should fix it. + + +**1.0.6** - updated example - updated pytproject deps diff --git a/nunchaku_compat.py b/nunchaku_compat.py index 0399c19..a3fae47 100644 --- a/nunchaku_compat.py +++ b/nunchaku_compat.py @@ -189,6 +189,46 @@ def apply_nunchaku_patches(): nn.Module.__call__ = patched_module_call + # Also patch TiledDiffusion if present + try: + import sys + if 'ComfyUI-TiledDiffusion.tiled_diffusion' in sys.modules: + tiled_diff = sys.modules['ComfyUI-TiledDiffusion.tiled_diffusion'] + if hasattr(tiled_diff, 'TiledDiffusion'): + original_tiled_call = tiled_diff.TiledDiffusion.__call__ + + def patched_tiled_call(self, model_function, kwargs): + """Wrap TiledDiffusion to handle 5D tensors from Qwen Image models""" + x_in = kwargs.get('input', None) + + # Check if we have a 5D tensor + if x_in is not None and len(x_in.shape) == 5: + # Shape is [N, C, F, H, W], squeeze F dimension if it's 1 + N, C, F, H, W = x_in.shape + + if F == 1: + print(f"[Nunchaku Compat] TiledDiffusion: Squeezing 5D tensor {list(x_in.shape)} -> 4D") + kwargs['input'] = x_in.squeeze(2) # Remove F dimension + + # Call original with 4D tensor + result = original_tiled_call(self, model_function, kwargs) + + # Restore 5D shape if result is 4D + if isinstance(result, torch.Tensor) and len(result.shape) == 4: + result = result.unsqueeze(2) # Add F dimension back + print(f"[Nunchaku Compat] TiledDiffusion: Restored to 5D shape {list(result.shape)}") + + return result + else: + print(f"[Nunchaku Compat] TiledDiffusion: Warning - 5D tensor with F={F} (not 1), cannot safely squeeze") + + return original_tiled_call(self, model_function, kwargs) + + tiled_diff.TiledDiffusion.__call__ = patched_tiled_call + print("[Nunchaku Compat] Successfully patched TiledDiffusion for 5D tensor support") + except Exception as e: + print(f"[Nunchaku Compat] Could not patch TiledDiffusion (not installed or incompatible): {e}") + print("[Nunchaku Compat] Successfully installed Nunchaku compatibility patches") _patch_applied = True diff --git a/pyproject.toml b/pyproject.toml index 5bec545..dbc4886 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "erosdiffusion-eulerflowmatchingdiscretescheduler" description = "Noise Free images with Euler Discrete Scheduler in ComfyUI with Z-Image or other models" -version = "1.0.6" +version = "1.0.7" license = {file = "LICENSE.TXT"} dependencies = ["diffusers"] # classifiers = [