优化分块,数量为0则跳过节点

This commit is contained in:
AI_Architect
2026-06-29 03:46:34 +08:00
parent a294cd1b5d
commit 30c8ebe650
+10
View File
@@ -82,6 +82,11 @@ class XB_UNetBlockSwap:
if is_dynamic_vram_active():
return (unet_model,)
# ── blocks_to_swap=0 等同于关闭,直接穿透 ──
if blocks_to_swap == 0:
print("\033[96m[XB UNet Block Swap]\033[0m: 分块数量为 0,节点穿透(无操作)")
return (unet_model,)
def swap_blocks(model_patcher: ModelPatcher, device_to, lowvram_model_memory, force_patch_weights, full_load):
base_model = model_patcher.model
# 🛡️ 动态获取 ComfyUI 分配的 GPU 设备,绝不写死 'cuda:0'
@@ -159,6 +164,11 @@ class XB_CheckpointBlockSwap:
if is_dynamic_vram_active():
return (checkpoint_model,)
# ── blocks_to_swap=0 等同于关闭,直接穿透 ──
if blocks_to_swap == 0:
print("\033[96m[XB Checkpoint Block Swap]\033[0m: 分块数量为 0,节点穿透(无操作)")
return (checkpoint_model,)
def swap_blocks(model_patcher: ModelPatcher, device_to, lowvram_model_memory, force_patch_weights, full_load):
base_model = model_patcher.model
# 🛡️ 动态获取 ComfyUI 分配的 GPU 设备