Commit Graph
19 Commits
Author SHA1 Message Date
Adrien Toupet e89a8b00a5 feat: promote cond_noise_scale to UI for controlling conditioning noise level helping mitigate noise artifacts in high-res upscaling 2025-09-18 23:19:35 -04:00
Adrien Toupet ee95a3a673 feat: Add configurable color correction methods and improve memory management
- Add color_correction parameter (wavelet/adain/none) to both ComfyUI node and CLI interface to choose between wavelet reconstruction (frequency-based), AdaIN (statistical matching), or no color correction
- Improve memory management after upscaling batches with targeted clear_memory calls to reduce VRAM pressure during VAE decoding
2025-09-16 22:21:45 -04:00
Adrien Toupet 1518ecc1a5 refactor: Fix ComfyUI node conflicts via relative imports and clearer model structure
- Renamed model directories for clarity: dit -> dit_7b, dit_v2 -> dit_3b
- Converted all absolute imports to relative imports throughout codebase
- Removed sys.path.append() manipulations that caused namespace conflicts
- Updated YAML configs to reference renamed model directories
- Simplified model variant detection logic using new directory names
- Standardized function calls with named arguments for better clarity
- Fixed generation context initialization and interrupt handling

This resolves import conflicts with other ComfyUI nodes (e.g., Basic data handling)
that use sys.path manipulation, making the module properly isolated and compatible.

Fixes #29, #114, #136
2025-09-16 16:45:31 -04:00
Adrien Toupet 477f57fd5a Refactor: Three-phase batch processing pipeline for improved performance
Major architectural change to minimize model swapping overhead by processing
all batches in three distinct phases instead of sequential per-batch processing:
- Phase 1: Encode all batches with VAE
- Phase 2: Upscale all latents with DiT
- Phase 3: Decode all latents with VAE

Core changes:
- Split monolithic generation_loop into modular functions:
  - prepare_generation_context(): Shared state management
  - setup_device_environment(): Device configuration
  - prepare_runner(): Model loading with cache support
  - encode_all_batches(): Batch VAE encoding
  - upscale_all_batches(): Batch DiT upscaling
  - decode_all_batches(): Batch VAE decoding
- Removed generation_step function (logic integrated into upscale phase)
- Added lazy precision initialization to avoid redundant setup

Performance improvements:
- Pre-allocated lists for memory efficiency
- Better cleanup of intermediate storage between phases
- Added unique timer names to clear_memory() to avoid naming conflicts
- Improved model state management with change detection and caching

UI/UX enhancements:
- Switched to ComfyUI's native ProgressBar with weighted phase progress
- Changed from per-batch FPS to overall average FPS (always visible)
- Improved log clarity with clear phase separators
- Added ASCII art logo to clearly identify SeedVR2 process start
- Better progress tracking with weighted percentages across three phases

Code cleanup:
- Removed deprecated timer_context from Debug class
- Removed unused time imports across multiple files
- Fixed LOCAL_RANK environment variable to handle string conversion properly
- Improved error handling with try/except/finally blocks in all phases
2025-09-16 14:38:57 -04:00
Adrien Toupet 5595d58597 refactor: streamline generation pipeline and improve dtype handling
- Merge generation setup log steps: combine "Model Configuration" and "Input Preparation" into unified "Generation Setup" step
- Simplify dtype handling: remove redundant vae_dtype variable, VAE now uses configured dtype consistently
- Remove platform-specific VAE dtype logic (MPS special case)
- Unify VAE encode/decode: remove autocast wrapper and target_dtype parameter, both now use configured dtype
- Add consistent docstrings for vae_encode and vae_decode methods
- Improve precision logging: show both DiT and VAE dtypes, rename model_dtype to dit_dtype
- Optimize text embeddings movement: only move when preserve_vram is active (BlockSwap handles model layers separately)
- Load text embeddings directly to CPU when preserve_vram is enabled
- Update logging consistency: uppercase device names, unified category names, clearer messages
- Clarify FP8 RoPE conversion log message: specify "from FP8 to BFloat16"
2025-08-25 17:11:29 -04:00
Adrien Toupet 2053a80f38 refactor(WIP): Improve debug logging consistency and reduce redundancy
- Remove "Force move weights to device" in FP8CompatibleDiT forward() to avoid clash with blockswap - This was used for preserve_vram but will refactor preserve_vram in a separate commit
- Remove duplicate dtype detection in generation_step (now passed from generation_loop)
- Add device checks before CPU moves to avoid redundant operations
- Improve debug.log and debug.log_memory_state()  formatting, content, and categories for better visibility
- Remove unused imports and excessive clear_memory() calls
- Clean up non-essential logs from always display
2025-08-22 15:38:00 -04:00
Benjamin Herb 22aa85abb7 fix: Updates --prepend_frames logic 2025-08-21 08:12:07 +02:00
lihaoyun6 3b0699ead9 Merge remote-tracking branch 'upstream/nightly' 2025-08-12 22:28:36 +08:00
Benjamin Herb cd2671bbe1 fix: fixed tiling issue and added smoother blending
- Fixed issue that would lead to a white border around the image due to
  improper tile blending
- Added smoother blending (hann ramp) for the tiles and temporal
  overlaps
2025-08-10 23:54:17 +02:00
Benjamin Herb 126ebfc10e feat: add separate height/width control to vae tile size and overlap
- use h/w tuples to specify tiling size and overlap to allow for finer
    control
  - added OneOrTwoValues class to handle CLI input of single values or h/w
    pairs
2025-08-10 21:27:54 +02:00
Benjamin Herb afafa67dd8 fix: VAE tiling cleanup and fixes
- Fix issues with unnecessary VAE blocks at the boundarys
- Updated VAE encode/decode logic to more closely match the original flow
- Better skip_frame log info
2025-08-09 19:23:25 +02:00
Benjamin Herb 7737efd22a feat: Add temporal overlap with blending and prepend frame options to CLI
- Add temporal overlap with crossfading (works with multi GPU)
- Add option to prepend frames to avoid artifacts at the start
2025-08-09 04:12:37 +02:00
Benjamin Herb ad62a12a3e feat: Add VAE tiling support
- Add VAE encode/decode tiling based on @Luke2642 approach
- Fix issues when tiling sequences
- Add CLI arguments for VAE tiling configuration
2025-08-09 02:30:28 +02:00
Benjamin Herb fe67b2a042 feat: Add BlockSwap support for standalone CLI and update logging
- Add BlockSwap CLI arguments and activation
- Fix imports to work without ComfyUI dependencies
- Update to new debugging framework
2025-08-09 02:27:42 +02:00
lihaoyun6 3b530dc983 Added MPS backend support (for running on macOS) 2025-08-06 18:52:33 +08:00
luchuanzhao 59850f6e40 Fix multi GPUs OOM 2025-07-11 11:29:13 +08:00
NumZ f3c704a502 Fix linux 2025-07-03 14:41:49 +02:00
NumZ ee70d2a72c Add MultiGPU Standalone inference 2025-07-03 04:48:34 +02:00
NumZ 5c27397a40 Add MultiGPU Standalone inference 2025-07-03 04:22:28 +02:00