Commit Graph
291 Commits
Author SHA1 Message Date
John Pollock 40d40ef9b6 Finished implementation of wanvideowrapper nodes, updated example workflows, added some benchmarking files for reference. 2025-10-10 13:40:37 -05:00
John Pollock db931d66c3 Add WanVideoControlnetLoader class for loading ControlNet models 2025-10-10 09:30:46 -05:00
John Pollock faef324975 correcting implementation of salvagable nodes and obiliterating one abomination 2025-10-10 09:28:58 -05:00
John Pollock 610c2102dd Add multi-GPU support for remaining planned WanVideo model loaders 2025-10-10 04:35:16 -05:00
John Pollock 375cbd093c Add LoadWanVideoClipTextEncoder and WanVideoClipVisionEncode for multi-GPU support 2025-10-09 19:05:28 -05:00
John Pollock 2f605e0db3 Add WanVideoVACEEncode and enhance WanVideoEncode for multi-GPU support
- Implemented WanVideoVACEEncode class for encoding with VACE, including input parameters for width, height, number of frames, and strength.
- Enhanced WanVideoEncode class to support multi-GPU encoding, with additional parameters for noise augmentation and latent strength.
- Updated device management to ensure proper device context during encoding processes.
2025-10-09 14:41:53 -05:00
John Pollock ba0a3a6e21 improve documentation on supporting ROCm cuda-enumerated GPUs. 2025-10-09 13:01:20 -05:00
John Pollock b04ae1e378 Coverted WanVideoImageToVideoEncode to shim 2025-10-09 12:32:29 -05:00
John Pollock f0313e49aa WanVideoDecode cleanup 2025-10-09 08:12:26 -05:00
John Pollock 15ff29c63b methodological convergence and cleanup 2025-10-09 03:06:25 -05:00
John Pollock 7c87983d72 WIP 2025-10-08 23:06:54 -05:00
John Pollock 04013c3ee5 feat: add WanVideoTextEncodeCached and WanVideoTextEncodeSingle classes for enhanced text encoding functionality 2025-10-08 06:08:16 -05:00
John Pollock d300c12e9f feat: add WanVideoBlockSwap class and integrate into MultiGPU node mappings 2025-10-07 14:22:01 -05:00
John Pollock 27cfb83733 feat: add MultiGPU logging enhancements and new CI scripts for workflow execution and log summarization, WanVidwoWrapper Model Loader/Sampler re-implemented 2025-10-07 13:19:09 -05:00
John Pollock b034901a05 Housecleaning 2025-10-07 04:00:12 -05:00
John Pollock 616a89c23f feat: add multi-GPU WanVideo VAE loader, encode, and decode nodes
- Added imports and registrations for WanVideoVAELoader, WanVideoTinyVAELoader,
  WanVideoImageToVideoEncode, and WanVideoDecode in multi-GPU versions.
2025-10-06 05:53:23 -05:00
John Pollock cfe6ebc70f Re-coded T5 loader and WanVideo Text Encoder 2/24 complete 2025-10-06 00:55:34 -05:00
John Pollock ddfc95d4a6 Deprecate HunyuanVideoWrapper support
Re-synchronize first node for WanVideoWrapper - LoadWanVideoT5TextEncoder
2025-10-05 23:54:41 -05:00
John Pollock dde3480a82 Merge pull request #117 - refactor: Replace keep_loaded with eject_models Boolean for improved memory management 2025-10-04 18:30:03 -05:00
John Pollock 0919fd4ccb Minor cleanup related to 2.5.1 release 2025-10-04 18:08:22 -05:00
John Pollock f60aa6a9a7 refactor: keep_loaded --> eject_models Boolean switch. Use it to eject all other models prior to loading model for inference; helpful to maximize available latent space on device prior to UNet inference, for example
So this is a change from something just newly-released in 2.5.0, but most should either see an improvement or no change to behavior. This was the weakest, and jankiest part of 2.5.0 and my decision to manage a CPU memory leak turned into a too-aggressive solution with unwanted side effects.

This solution should provide a better way to manage `compute` VRAM as the most asked-for feature is a way to remove everything else from VRAM prior to main UNet inference, which this accomplishes nicely, as well as reporting back accurate information DisTorch2 on-device shard sizes.
2025-10-04 17:42:52 -05:00
John Pollock 72a20338ef feat: patch load_models_gpu for accurate memory calculations; unpatch load_models_gpu
Refactor memory management in distorch_2.py to patch load_models_gpu instead of LoadedModel.model_memory_required. Implement correct memory reporting based on model flags (eject_models and is_distorch_model), ensuring proper eviction logic and improved handling of virtual VRAM. This drives behavior purely by either comfy core matching or DisTorch flag, fixing potential issues in multi-GPU setups.
2025-10-04 17:16:51 -05:00
John Pollock e6d19951d7 Paranoia before cleanup 2025-10-04 12:32:37 -05:00
John Pollock e3750fd737 minor changes 2025-10-04 09:27:33 -05:00
John Pollock ee41f46beb revert most changes 2025-10-04 06:47:08 -05:00
John Pollock d8616acd5e investigation 2025-10-04 05:29:32 -05:00
John Pollock a1b7b1fdcf Merge pull request #114 from pollockjj/d2_clip
Major Refactor
2025-09-30 20:38:39 -05:00
John Pollock 2a6a8f4c2b workflow cleanup 2025-09-30 20:33:48 -05:00
John Pollock a19e31c915 corrected instructions 2025-09-30 18:38:08 -05:00
John Pollock 24b27c4c83 docs: add node documentation guide to README
Add comprehensive guide for accessing and using documentation on core MultiGPU and DisTorch2 nodes, covering 36+ nodes with detailed parameters, outputs, and usage examples. This enhances user experience by providing easy reference for standard ComfyUI loaders and DisTorch2 features, while clarifying coverage excludes third-party nodes.
2025-09-30 18:32:57 -05:00
John Pollock 989b3dc4c3 additional standard loaders documentation 2025-09-30 18:10:51 -05:00
John Pollock 7e0d484b17 docs: Add documentation for standard, gguf, and DisTorch nodes/wrappers 2025-09-30 18:05:48 -05:00
John Pollock a8a5a6f1fd feat(__init__): add WEB_DIRECTORY constant for web assets path
Add a new constant WEB_DIRECTORY set to "./web" to define the directory path for web-related assets during package initialization. This improves organization by centralizing the path configuration. Additionally, removed trailing newline at file end to maintain consistent code formatting.
2025-09-30 17:02:59 -05:00
John Pollock 64d8ede091 prep for final release candidate 2025-09-30 10:41:14 -05:00
John Pollock b87505399f WIP 2025-09-30 10:38:16 -05:00
John Pollock 486a84e357 prep for final release candidate 2025-09-30 09:52:00 -05:00
John Pollock 62752d1bbf Standardize doc strings and make PEP 257 compliant 2025-09-30 09:34:41 -05:00
John Pollock fc2a732419 prepare for final release candidate 2025-09-30 09:15:32 -05:00
John Pollock 9a526e2546 prepare for final release candidate 2025-09-30 09:10:37 -05:00
John Pollock 23ed34df1b prepare for final release candidate 2025-09-30 09:08:15 -05:00
John Pollock 429be7c912 docs: update activeContext for v2.5.0 release with refactoring summary
Update active context documentation to reflect v2.5.0 release candidate status.
Major achievements documented:

- DisTorch2 allocation refactoring (-179 lines, unified UNET/CLIP logic)
- Production cleanup removing debug instrumentation (-40 lines)
- Verified selective unload system working with production logs
- Architecture status showing all core files production-ready
- Updated memory management pipeline with verification details

Reorganized content to prioritize recent session achievements (2025-09-30)
and production readiness status. Total code reduction: 219 lines through
consolidation and cleanup while maintaining full functionality.
2025-09-30 09:07:05 -05:00
John Pollock e7d8113a86 refactored in to one analyze_safetensor_loading 2025-09-30 08:44:16 -05:00
John Pollock 8b8a16e982 Major architectural refactor: Consolidate wrappers, fix CheckpointLoader bug, improve separation of concerns (-531 lines)
This commit represents a significant architectural refactoring to improve code organization,
eliminate redundancy, and fix a critical bug in wrapper functions. Net reduction of 531 lines
while improving maintainability and fixing functionality.

## wrappers.py (NEW FILE: +531 lines)
- Created dedicated module for ALL node wrapper/override functions
- Consolidated 10 wrapper types from 3 different files into single location:
  * DisTorch V2 SafeTensor wrappers (factory + 3 implementations)
  * DisTorch V1 legacy wrappers (4 GGUF/CLIP wrappers, rewritten to call V2 backend)
  * Standard MultiGPU wrappers (3 device selection wrappers)
- CRITICAL FIX: All wrappers now strip MultiGPU-specific parameters before calling
  original ComfyUI functions (fixes CheckpointLoaderSimple TypeError)
- Improved architecture: clear separation between wrapper UI and backend logic

## distorch.py (DELETED: -529 lines)
- Removed entire legacy DisTorch V1 file
- All V1 wrapper functions moved to wrappers.py and rewritten to call V2 backend
- Backend allocation functions no longer needed (V2 backend handles all cases)
- Eliminates code duplication and maintenance burden

## distorch_2.py (-409 lines)
- Removed duplicate _create_distorch_safetensor_v2_override factory function
  (was incorrectly present in both distorch_2.py and wrappers.py)
- Removed 3 wrapper export functions (moved to wrappers.py)
- File now contains ONLY backend logic:
  * register_patched_safetensor_modelpatcher()
  * analyze_safetensor_loading() and analyze_safetensor_loading_clip()
  * calculate_safetensor_vvram_allocation()
  * Allocation stores and model hash functions
- Added clear documentation comment about wrapper migration

## __init__.py (-230 lines)
- Removed 3 local wrapper function definitions (moved to wrappers.py)
- Removed soft_empty_cache_distorch2_patched (moved to device_utils.py)
- Removed all distorch.py imports (file deleted)
- Added imports from new wrappers.py module (10 wrapper functions)
- Updated imports from distorch_2.py (backend functions only, no wrappers)
- Improved architecture: __init__.py now focused on initialization and registration

## device_utils.py (+68 lines)
- Moved soft_empty_cache_distorch2_patched() from __init__.py
- Added comprehensive memory management patch in architecturally correct location
- Patch includes:
  * DisTorch2 detection and multi-device VRAM management
  * Adaptive CPU memory threshold checking
  * Force flag support for executor cache reset (Manager parity)
- Applied patch at module level: mm.soft_empty_cache = soft_empty_cache_distorch2_patched
- Behavior preserved: patch still executes when device_utils is imported by __init__.py

## nodes.py (-30 lines)
- Removed unused wrapper function imports
- Cleaned up import statements to reflect new architecture

## Impact Summary
- Improved architecture: Clear separation between wrappers (UI) and backend (logic)
- Eliminated distorch.py: Reduced from 3 files to 2 (wrappers.py + distorch_2.py)
- Net code reduction: 531 lines removed while adding functionality
- Better maintainability: Single source of truth for all wrapper functions
- Preserved behavior: All patches execute correctly, no functional changes

## Breaking Changes
None - this is a pure refactor with no API or behavioral changes.
2025-09-30 08:13:21 -05:00
John Pollock 07b429f3f9 fix(distorch): Add GC anchor protection for selective model retention
Problem: Models correctly categorized as "keep loaded" during selective
unload were disappearing before the next cleanup cycle. After reassigning
mm.current_loaded_models = kept_models, Python's garbage collector would
clear the models because the list was their only remaining strong reference.

Solution: Implement GC anchor system using a global set to hold strong
references to ModelPatcher objects that must survive cleanup cycles.

Changes:
- Add _MGPU_RETENTION_ANCHORS global set and helper functions
- Add early delegation check: if no DisTorch models want unload, clear
  anchors and delegate to original unload_all_models
- Add retention anchor when categorizing kept models
- Clear anchors before delegating to allow normal cleanup

Result: Self-contained, reversible protection mechanism. Models with
keep_loaded=True survive automatic cleanup but can be cleared with
explicit "Clear All Models" button. Tested on both keep_loaded=True
and keep_loaded=False scenarios.

Refs: memory-bank/distorch_selective_unload_solution.md
2025-09-29 16:01:24 -05:00
John Pollock bde51c6236 docs(distorch): document GC anchor solution for selective unload
Add comprehensive documentation for the DisTorch selective model unload
solution that addresses Python garbage collection issues. The document
details:

- Problem: Models with keep_loaded=False were being prematurely garbage
  collected despite being added to current_loaded_models list
- Root cause: Reassigning current_loaded_models created the only strong
  reference, making models vulnerable to GC between assignment and next
  access
- Solution: Global GC anchor set (_MGPU_RETENTION_ANCHORS) maintains
  strong references to ModelPatcher objects that should survive cleanup
- Implementation: Early delegation check, anchor protection during
  categorization, and explicit lifecycle management
- Testing results: Confirms Flux unloads while VAE/CLIP remain protected

This solution ensures DisTorch models can selectively unload while
keeping VAE and CLIP models loaded, preventing memory management race
conditions with Python's garbage collector.
2025-09-29 15:45:46 -05:00
John Pollock c23dc083d3 WIP 2025-09-29 14:04:05 -05:00
John Pollock 6e1f9671f2 docs(memory): update Phase 3 implementation status and clarify bug
Update documentation to reflect that Phase 3 selective ejection is now
fully deployed in code, including per-model flags, patched unload_all_models,
and Manager parity via force_full_system_cleanup.

Clarify understanding of remaining bug:
- Remove incorrect hypothesis that "all-kept delegation" causes the issue
- Document that delegation to original unload_all_models is intentional
  behavior needed for post-execution cleanup
- Simplify bug description to acknowledge root cause is still unknown
- Focus on observable symptom: retained models (keep_loaded=True) are
  still being ejected despite selective unload logic being present

This commit corrects misleading documentation and removes false leads
to help focus investigation on the actual unknown root cause.
2025-09-29 13:21:57 -05:00
John Pollock 01df082651 docs(memory-bank): sync with current code state for selective ejection\n\n- Document Phase 3 implemented without global sentinel (_mgpu_unload_distorch_model per-model flag)\n- Describe patched unload_all_models selective behavior and current all-kept delegation caveat\n- Outline rediscovery plan and strict no-op target when no models are flagged\n- Update active context, system patterns, code references, progress, tech context, and lineage 2025-09-29 07:57:35 -05:00
John Pollock 1ca3daf0d8 At least now the logs reflect it is now trying to do what I know we have figured out how to do in the past in one of these commits. . . 2025-09-29 07:08:03 -05:00
John Pollock d61ca7b06f back to setting full reset flag if there is a distorch unload pending. 2025-09-29 05:27:53 -05:00