Refactor: Simplify block swap analysis and cleanup .gitignore

This commit removes the unused `reserved_swap_gb` parameter from the `analyze_safetensor_distorch` function and its call sites. This simplifies the function's signature and cleans up the analysis output by removing the "Reserve" metric, which was always zero.

Additionally, the `.gitignore` file is simplified by removing entries for the `binaries/` directory, which are no longer needed.
This commit is contained in:
John Pollock
2025-08-11 12:47:25 -05:00
parent 372217e901
commit 62718ea12f
2 changed files with 4 additions and 15 deletions
+1 -12
View File
@@ -1,14 +1,3 @@
# Python and IDE
__pycache__/
.vscode/settings.json
# Binary management
binaries/*
binaries/win64/*
binaries/linux/*
# Keep directory structure and rename file for Linux
!binaries/
!binaries/win64/
!binaries/linux/
!binaries/linux/rename_this_to_keep_user_binary.txt
.vscode/settings.json
+3 -3
View File
@@ -10,7 +10,7 @@ from collections import defaultdict
import comfy.model_management as mm
def analyze_safetensor_distorch(model, compute_device, swap_device, virtual_vram_gb, reserved_swap_gb, all_blocks):
def analyze_safetensor_distorch(model, compute_device, swap_device, virtual_vram_gb, all_blocks):
"""Provides a detailed analysis of the block swap configuration, mimicking the GGUF DisTorch style."""
eq_line = "=" * 60
@@ -28,7 +28,7 @@ def analyze_safetensor_distorch(model, compute_device, swap_device, virtual_vram
compute_total_gb = mm.get_total_memory(torch.device(compute_device)) / (1024**3)
swap_total_gb = mm.get_total_memory(torch.device(swap_device)) / (1024**3)
logging.info(fmt_assign.format(compute_device, "Compute", f"{compute_total_gb:.2f}", f"Reserve: {reserved_swap_gb:.2f}"))
logging.info(fmt_assign.format(compute_device, "Compute", f"{compute_total_gb:.2f}", ""))
logging.info(fmt_assign.format(swap_device, "Swap", f"{swap_total_gb:.2f}", f"Offload: {virtual_vram_gb:.2f}"))
logging.info(dash_line)
@@ -124,7 +124,7 @@ def apply_block_swap(model_patcher, compute_device="cuda:0", swap_device="cpu",
logging.info(f"[DisTorch SafeTensor] Successfully identified {len(all_blocks)} swappable blocks.")
# Run and display the analysis
analyze_safetensor_distorch(model_to_patch, compute_device, swap_device, virtual_vram_gb, 0.0, all_blocks)
analyze_safetensor_distorch(model_to_patch, compute_device, swap_device, virtual_vram_gb, all_blocks)
model_size_gb = sum(p.numel() * p.element_size() for p in model_to_patch.parameters()) / (1024**3)
block_size_gb = model_size_gb / len(all_blocks) if all_blocks else 0