From d00c025a5e3632f2299acb3811f228396846b522 Mon Sep 17 00:00:00 2001 From: mi804 <1576993271@qq.com> Date: Tue, 4 Aug 2026 16:16:56 +0800 Subject: [PATCH 1/3] update version to 2.1.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a75340344..ab98835e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "diffsynth" -version = "2.0.18" +version = "2.1.0" description = "Enjoy the magic of Diffusion models!" authors = [{name = "ModelScope Team"}] license = {text = "Apache-2.0"} From 6bd3817ec42a011dd0632ab04ee79c6b865a74db Mon Sep 17 00:00:00 2001 From: mi804 <1576993271@qq.com> Date: Tue, 25 Aug 2026 15:39:44 +0800 Subject: [PATCH 2/3] Expose the error type for audio load. --- diffsynth/core/data/operators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diffsynth/core/data/operators.py b/diffsynth/core/data/operators.py index 4f80b01ec..9f6bc5ab9 100644 --- a/diffsynth/core/data/operators.py +++ b/diffsynth/core/data/operators.py @@ -307,8 +307,8 @@ def __call__(self, data: str): padding = target_samples - current_samples waveform = torch.nn.functional.pad(waveform, (0, padding)) return waveform, sample_rate - except: - warnings.warn(f"Cannot load audio in {data}. The audio will be `None`.") + except Exception as e: + warnings.warn(f"Cannot load audio in {data} due to {e}. The audio will be `None`.") return None From 9b6d6bc90ccf4456bb9a09e7bd627292831c2f6c Mon Sep 17 00:00:00 2001 From: mi804 <1576993271@qq.com> Date: Wed, 26 Aug 2026 19:38:10 +0800 Subject: [PATCH 3/3] fix quanized model's lora hotload --- diffsynth/core/loader/model.py | 3 +++ diffsynth/core/vram/layers.py | 7 +++++-- diffsynth/diffusion/base_pipeline.py | 10 +++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/diffsynth/core/loader/model.py b/diffsynth/core/loader/model.py index 64a22cca6..340e87aa1 100644 --- a/diffsynth/core/loader/model.py +++ b/diffsynth/core/loader/model.py @@ -119,6 +119,9 @@ def load_model(model_class, path, config=None, torch_dtype=torch.bfloat16, devic # Because some models override the behavior of `to()`, # especially those from libraries like Transformers. model = model.to(dtype=torch_dtype, device=device) + if quantize is not None: + # Downstream steps (e.g. LoRA hot-loading) need the config to handle the quantized layers. + model.quantize_config = quantize if hasattr(model, "eval"): model = model.eval() return model diff --git a/diffsynth/core/vram/layers.py b/diffsynth/core/vram/layers.py index fde062426..716d1d09b 100644 --- a/diffsynth/core/vram/layers.py +++ b/diffsynth/core/vram/layers.py @@ -442,7 +442,7 @@ def forward(self, x, *args, **kwargs): return out -class AutoWrappedQuantizedModule(AutoTorchModule, LoRAHotLoadMixin): +class AutoWrappedQuantizedModule(torch.nn.Linear, AutoTorchModule, LoRAHotLoadMixin): def __init__( self, module: torch.nn.Module, @@ -467,7 +467,8 @@ def __init__( "Disk offload for quantized layers requires both `disk_map` and `quantize`, " "so each layer can rebuild its packed weight and quant state lazily." ) - super().__init__( + AutoTorchModule.__init__( + self, offload_dtype, offload_device, onload_dtype, @@ -478,6 +479,8 @@ def __init__( computation_device, vram_limit, ) + self.in_features = module.in_features + self.out_features = module.out_features self.module = module self.name = name self.disk_offload = disk_offload diff --git a/diffsynth/diffusion/base_pipeline.py b/diffsynth/diffusion/base_pipeline.py index 907c731b2..5af48a110 100644 --- a/diffsynth/diffusion/base_pipeline.py +++ b/diffsynth/diffusion/base_pipeline.py @@ -240,6 +240,13 @@ def flush_vram_management_device(self, device): module.computation_device = device + def check_quant_hot_load(self, module: torch.nn.Module): + # A quantized weight cannot absorb a fused LoRA, so hot-loading is the only option for it. + if getattr(module, "quantize_config", None) is None: + return module + return self.enable_lora_hot_loading(module) + + def load_lora( self, module: torch.nn.Module, @@ -249,6 +256,7 @@ def load_lora( state_dict=None, verbose=1, ): + module = self.check_quant_hot_load(module) if state_dict is None: if isinstance(lora_config, str): lora = load_state_dict(lora_config, torch_dtype=self.torch_dtype, device=self.device) @@ -370,7 +378,7 @@ def enable_lora_hot_loading(self, model: torch.nn.Module): "computation_dtype": self.torch_dtype, "computation_device": self.device, } - model = enable_vram_management(model, module_map, vram_config=vram_config) + model = enable_vram_management(model, module_map, vram_config=vram_config, quantize=getattr(model, "quantize_config", None)) return model def compile_pipeline(self, mode: str = "default", dynamic: bool = True, fullgraph: bool = False, compile_models: list = None, **kwargs):