Commit Graph
14 Commits
Author SHA1 Message Date
diodiogod f285fa8bd2 Fix ComfyUI model wrapper compatibility with ComfyUI 0.18 memory management
Technical details:
- Add model_mmap_residency fallback to the shared ComfyUI wrapper
- Add pinned memory, dtype, patcher, and device compatibility methods
- Return full model memory for non-mmap-backed engines instead of a zero stub
- Add regression coverage for wrapper compatibility behavior

Fixes #276
Fixes #278
2026-03-27 09:25:38 -03:00
diodiogod 69c8d7bcee Version 4.20.18
Fix Higgs Audio CUDA graph crashes on model reload

Implementation:
- Only reset cuda_graphs_initialized flag on unload, minimal intervention
- Let Higgs Audio's natural lazy initialization recreate graphs and caches
- Removed overly aggressive dict clearing that broke generation
- Cleaned up unnecessary debug prints from handler and engine startup
- Updated tooltip to clarify CUDA graphs are now safely manageable
- Removed legacy corruption flag checking in adapter (no longer needed)

This enables safe VRAM unloading with CUDA graphs enabled while preserving
audio quality and generation speed after model recreation.
2026-02-06 23:22:10 -03:00
diodiogod 2811a6225f Version 4.20.14
Fix ComfyUI model wrapper compatibility for TTS engines

Technical details:
- Add partially_unload_ram shim in ComfyUIModelWrapper
- Delegate to existing partial unload path to avoid AttributeError on newer ComfyUI
2026-02-05 09:51:25 -03:00
diodiogod 51730916f0 Version 4.20.4
Add ComfyUI 0.12.0+ compatibility

Technical details:
- Add is_dynamic() method to ComfyUIModelWrapper
- Fix AttributeError when ComfyUI 0.12+ calls is_dynamic() on TTS models
- Address issue #247 reported by wasd-tech
2026-02-03 17:23:44 -03:00
diodiogod a2e11108e2 Version 4.19.5
Fix CosyVoice device mismatch in voice restoration

Technical implementation:
- Add CosyVoiceHandler.partially_load() for proper device reload
- Update base_wrapper.model_load() to use handler's partially_load()
- Move all CosyVoice components (llm, flow, hift, campplus) with nested modules
- Simplify CosyVoice engine wrapper device management (delegate to handler)
- Add CosyVoice variant setting for <restore> tags (RL/standard options)
- Update settings UI and API endpoint for variant selection

Fixes device tensor mismatch errors when TTS and VC restoration run sequentially
and prevents unnecessary model unload/reload when variants match.
2026-01-28 13:22:29 -03:00
diodiogod 08b52f63c3 Add inline edit tag support for Higgs Audio and fix CUDA graph unloading crash
Added edit tag extraction and batch processing for Higgs Audio TTS and SRT processors following the established pattern from VibeVoice and Step Audio EditX.

Key changes:
- Extract edit tags at top level before pause processing to keep nested functions returning tensors
- Apply edit post-processing after all audio generation completes
- For SRT: batch process all subtitle edits at end instead of per-subtitle
- Fix CUDA graph crash: detect original engine for stateless wrappers and refuse unloading when CUDA graphs enabled
- Store original_engine in ModelInfo to track Higgs even when masked as stateless_tts
- Update Higgs handler to check correct attribute paths for _cuda_graphs_enabled flag

Files modified:
- nodes/higgs_audio/higgs_audio_tts_processor.py: Add edit tag extraction and post-processing
- nodes/higgs_audio/higgs_audio_srt_processor.py: Batch edit processing for all subtitles
- utils/models/comfyui_model_wrapper/base_wrapper.py: Track original_engine for masked engines
- utils/models/comfyui_model_wrapper/model_manager.py: Store original engine when masking
- utils/models/comfyui_model_wrapper/engine_handlers/higgs_audio_handler.py: Refuse unload when CUDA graphs enabled
- docs/Dev reports/SRT_Edit_Tag_Batch_Processing_Pattern.md: Mark Higgs as implemented
2025-12-06 19:04:27 -03:00
diodiogod 8018ce70da Fix model cache key matching to distinguish between different model variants
Fixed issue where switching between different models of the same engine (e.g.,
vibevoice-7B to vibevoice-1.5B) would cause OOM by trying to load wrong model:

- Added cache_key parameter to ComfyUIModelWrapper so wrapper knows its specific identity
- Updated ensure_device() to accept model_cache_key and clear same-engine-different-variant models
- Fixed ensure_device() to use cache_key directly when provided instead of searching by engine
- Removed ensure_device() call from VibeVoice generation path (was causing OOM during inference)
- Added device string normalization to handle cuda vs cuda:0 comparison differences

Now properly handles:
- Switching between vibevoice-7B and vibevoice-1.5B (clears old model from GPU)
- Different quantization variants (4bit vs full precision treated as separate models)
- Multiple model variants coexisting in CPU cache for fast reload
2025-12-06 16:44:30 -03:00
diodiogod 3627980bc5 Fix VRAM management with proper model clearing and synchronization
Resolved OOM errors during model switching by implementing proper VRAM clearing:
- Added real VRAM measurement using torch.cuda.memory_allocated() in model_manager
- Removed fake VRAM reporting from VibeVoice handler
- Removed class-level caching from VibeVoice engine (unified manager handles all caching)
- Centralized device movement through ensure_device() in model manager
- Models now move to CPU instead of deletion for fast reload from cache
- Added CUDA synchronization after clearing to ensure memory is actually freed
- Fixed recursion by adding _from_ensure_device flag to model_load()
- model_load() now calls ensure_device() first to clear other models before loading

Also fixed inline edit tag spacing issues:
- Tags now properly add space after paralinguistic tags when followed by alphanumeric text
- Fixed both parser and post-processor to handle spacing correctly
2025-12-06 16:18:32 -03:00
diodiogod b8acd9dc4e Version 4.14.23
Complete model loading architecture refactor (Tier 2 + Tier 3)

Address issue #14

Technical implementation:
- Remove SmartModelLoader third caching system (complete)
- Standardize all factories to use ModelLoadConfig dataclass
- Fix unified interface to return wrapped models for Clear VRAM support
- Add __getattr__ to ComfyUIModelWrapper for transparent attribute forwarding
- Clean up legacy wrapper-searching code in base_node.py and processors
- Create engine registry with capability definitions
- Implement generic FallbackHandler for language fallback chains
- Add TTSModelLoadingError exception hierarchy
- Delete SmartModelLoader dead code (9.8KB removed)

Files modified:
- nodes/chatterbox/chatterbox_tts_node.py (2 SmartModelLoader removals)
- engines/chatterbox/streaming_model_manager.py (unified interface migration)
- engines/chatterbox_official_23lang/streaming_model_manager.py (unified interface migration)
- engines/adapters/f5tts_streaming_adapter.py (unified interface migration)
- utils/models/unified_model_interface.py (return wrapper instead of wrapper.model)
- utils/models/comfyui_model_wrapper/base_wrapper.py (add __getattr__)
- nodes/base/base_node.py (simplify wrapper detection)
- nodes/chatterbox_official_23lang/chatterbox_official_23lang_processor.py (simplify wrapper detection)
- engines/vibevoice_engine/vibevoice_engine.py (simplify device reload)

Created files:
- utils/models/factory_config.py (ModelLoadConfig standard)
- utils/models/engine_registry.py (engine capabilities registry)
- utils/models/fallback_handler.py (generic fallback chain utility)
- utils/models/exceptions.py (standardized exception hierarchy)

Deleted files:
- utils/models/smart_loader.py (obsolete third caching system)
2025-11-14 22:54:40 -03:00
diodiogod 573c2497d3 Add MPS (Apple Silicon) support for all TTS engines
- Created utils/device/torch_device_resolver.py with intelligent device detection
  - Supports MPS (Metal Performance Shaders) for Apple Silicon
  - Fallback chain: MPS > CUDA > CPU for auto-detection
  - Safe detection with torch.backends.mps.is_available() checks

- Updated all 7 engine nodes to expose 'mps' device option:
  - ChatterBox, F5-TTS, Higgs Audio, VibeVoice
  - ChatterBox Official 23-Lang, Index TTS, RVC

- Integrated device resolver across all engine implementations:
  - unified_model_interface.py (central point)
  - comfyui_model_wrapper/base_wrapper.py (ComfyUI integration)
  - All direct engine implementations (VibeVoice, Higgs Audio, F5-TTS edit, etc.)

- Maintains backward compatibility:
  - Existing workflows unchanged
  - MPS added as final option in device dropdowns
  - No behavior changes for Linux/Windows users

Resolves #160 - Users on Apple Silicon can now select MPS for GPU acceleration
2025-11-04 19:13:57 -03:00
diodiogod e373c49305 Fix RVC Clear VRAM button - register models with ComfyUI tracking
RVC models were being cached in minimal wrapper but not tracked by ComfyUI,
so Clear VRAM button couldn't see them.

Changes:
- Added is_dead() and model_memory() methods to ComfyUIModelWrapper for ComfyUI compatibility
- Created SimpleModelWrapper class for models without nested .model attribute
- RVC models now register with ComfyUI's current_loaded_models list on load
- Hubert models wrapped with SimpleModelWrapper to add .model attribute for logging
- Added device checking on cached model reuse - reloads from CPU to CUDA when needed
- Models re-register with ComfyUI after reload to stay tracked
- Extracted registration logic into helper methods to avoid duplication
- Updated clear_model_cache() to remove RVC models from ComfyUI tracking

RVC Clear VRAM now works correctly across multiple generation cycles.
2025-10-27 23:02:23 -03:00
diodiogod 43cd4f5bd9 Version 4.11.24
Fix ChatterBox Official 23-Lang device placement bug

Technical implementation:
- Add .to() method to ChatterBoxOfficial23LangTTS class for device migration
- Add .to() method to ChatterboxVC class for voice conversion device handling
- Improve wrapper's _move_all_components_to_device() with better recursion depth
- Fix unified_model_interface device resolution for 'auto' mode
- Add ComfyUI model management re-registration after wrapper.model_load()
- Fix model_finalizer setup when re-registering with ComfyUI
- Add device check in processor to call wrapper.model_load() instead of direct .to()

Fixes device mismatch errors:
- Fix 'Expected all tensors to be on the same device' error on second run
- Fix 'Inference tensors do not track version counter' after CPU detachment
- Fix 'Clear VRAM' button not working after model reload
2025-10-27 19:10:52 -03:00
diodiogod c5c227b996 Version 4.10.11
Fix VibeVoice SageAttention compatibility issues

Technical improvements:
- Replace aggressive Qwen2Attention monkey-patching with safer SDPA wrapper approach
- Implement Enemyx-net's temporary F.scaled_dot_product_attention patching method
- Add proper EOS token handling for correct generation termination
- Fix model state corruption when switching between attention modes
- Add automatic fallback to original SDPA if SageAttention fails
- Eliminate need for ComfyUI restart when changing attention modes

Credits: SageAttention implementation approach adapted from @Enemyx-net's VibeVoice-ComfyUI
2025-09-26 12:10:08 -03:00
diodiogod d01e5cb807 Refactor comfyui_model_wrapper.py into modular architecture
- Split 970-line monolith into focused modules following 500-600 line policy
- Created utils/models/comfyui_model_wrapper/ directory structure:
  - base_wrapper.py (302 lines): Core ComfyUIModelWrapper class
  - model_manager.py (318 lines): ComfyUITTSModelManager class
  - cache_utils.py (28 lines): Cache invalidation utilities
  - engine_handlers/: Engine-specific memory management
    - higgs_audio_handler.py: CUDA graph management and unload blocking
    - vibevoice_handler.py: RAM cleanup and complete deletion logic
    - generic_handler.py: Standard CPU migration for other engines
- Fixed engine routing bug where stateless_tts wrappers weren't using HiggsAudioHandler
- Maintained full backward compatibility with existing imports
- All engine-specific behaviors preserved (VibeVoice deletion, Higgs CUDA graphs)
- Updated PROJECT_INDEX.md to reflect modular structure
2025-09-11 14:57:52 -03:00