From e238d2eaea8f6f831eacffa47754b7976cd49344 Mon Sep 17 00:00:00 2001 From: AI_Architect Date: Tue, 23 Jun 2026 09:52:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodes_wan.py | 29 +++++++++++++++++++++-------- nodes_wan_t5.py | 3 ++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/nodes_wan.py b/nodes_wan.py index a142aab..6b5a204 100644 --- a/nodes_wan.py +++ b/nodes_wan.py @@ -205,9 +205,13 @@ class XB_WanSampler: kw.update(extra) r = _wan_import("nodes_sampler").WanVideoSampler().process(**kw) if cleanup == "单次缓存清理": - torch.cuda.synchronize(); torch.cuda.empty_cache() + torch.cuda.synchronize() + torch.cuda.empty_cache() elif cleanup == "双次缓存清理": - torch.cuda.synchronize(); mm.soft_empty_cache(); torch.cuda.empty_cache(); gc.collect() + torch.cuda.synchronize() + mm.soft_empty_cache() + torch.cuda.empty_cache() + gc.collect() return r @@ -262,8 +266,10 @@ class XB_WanVAELoader: mod = _wan_import("wanvideo.wan_video_vae") cls = mod.WanVideoVAE38 if sd["model.conv2.weight"].shape[0] == 48 else mod.WanVideoVAE vae = cls(dtype=dtype, pruning_rate=pruning_rate, cpu_cache=use_cpu_cache) - vae.load_state_dict(sd); del sd - vae.eval(); vae.to(dtype=dtype) + vae.load_state_dict(sd) + del sd + vae.eval() + vae.to(dtype=dtype) print(f" [XB_WanVAELoader] {model_name} | {precision} | pruning={pruning_rate}") return (vae,) @@ -293,12 +299,19 @@ class XB_WanDecode: vae=vae, samples=samples, enable_vae_tiling=enable_vae_tiling, tile_x=tile_x, tile_y=tile_y, tile_stride_x=tile_stride_x, tile_stride_y=tile_stride_y) if cleanup == "单次缓存清理": - torch.cuda.synchronize(); torch.cuda.empty_cache() + torch.cuda.synchronize() + torch.cuda.empty_cache() elif cleanup == "双次缓存清理": - torch.cuda.synchronize(); mm.soft_empty_cache(); torch.cuda.empty_cache(); gc.collect() + torch.cuda.synchronize() + mm.soft_empty_cache() + torch.cuda.empty_cache() + gc.collect() elif cleanup == "卸载显存模型": - mm.unload_all_models(); mm.soft_empty_cache() - torch.cuda.synchronize(); torch.cuda.empty_cache(); gc.collect() + mm.unload_all_models() + mm.soft_empty_cache() + torch.cuda.synchronize() + torch.cuda.empty_cache() + gc.collect() return r diff --git a/nodes_wan_t5.py b/nodes_wan_t5.py index d2d2b9b..c5f28aa 100644 --- a/nodes_wan_t5.py +++ b/nodes_wan_t5.py @@ -139,7 +139,8 @@ class XB_WanT5Loader: if quantization == "disabled": for v in sd.values(): if isinstance(v, torch.Tensor) and v.dtype == torch.float8_e4m3fn: - quantization = "fp8_e4m3fn"; break + quantization = "fp8_e4m3fn" + break if "token_embedding.weight" not in sd and "shared.weight" not in sd: raise ValueError("Invalid T5 model, expected 'umt5-xxl' format") sd = _convert_t5_keys(sd)