Commit Graph
37 Commits
Author SHA1 Message Date
diodiogod 97f4a0c365 Add unified MOSS audio generation workflows 2026-07-16 12:35:01 -03:00
diodiogod 08916ea598 Fix MOSS download output and model lifecycle 2026-07-15 21:39:58 -03:00
diodiogod e471cdbaa6 Refine Dots TTS runtime and logging 2026-06-14 16:32:26 -03:00
diodiogod 2b69130a42 Add MOSS-TTS engine family with native TTSD support (#295)
* docs: add new engine integration guide flow

* docs: link new engine guide navigation

* docs: clarify SRT is required for TTS engines

* docs: document SRT reuse of TTS processor

* docs: move new engine guide link below timeline

* Add MOSS-TTS engine integration

* docs: add reference input mode to engine research

* Add MOSS-TTS engine checkpoint

* Refine MOSS prompt fields and parameter switching

* Refine MOSS prompt field warnings and caching

* Improve MOSS inline edit handling and VRAM handoff

* Improve MOSS native dialogue mapping and UI

* docs: add long-form model analysis and VibeVoice reference

* Improve MOSS TTSD chunking, interrupts, and SRT mapping

* Refine MOSS mapping, device checks, and metadata

* Make MOSS native incompatibilities hard-fail

* Document MOSS native hard-fail compatibility rules
2026-05-18 16:42:53 -03:00
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
drphero 2cc6387892 feat: register echo-tts with ComfyUI model manager
- add echo-tts factory in unified model interface
- ensure fish-s1-dac-min loads via the same managed path
- load echo-tts via unified interface for VRAM management
2026-03-01 00:45:16 -03:00
diodiogod 363553ecf9 Version 4.21.11: Fix model unloading GC crash and manager lazy import 2026-02-20 21:45:55 -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 9f725c83c6 Version 4.20.17
Fix Qwen3-TTS CUDA graph memory corruption on Windows

Technical details:
- Add Qwen3TTSHandler with proper CUDA graph cleanup
- Delete static tensors and graph objects before unload
- Force garbage collection to release memory pools
- Fix SRT node cache key to include optimization settings
- Prevent double-initialization when switching between TTS/SRT nodes

Address Windows cudaMallocAsync allocation conflicts that prevented
model reloading after VRAM clear when CUDA graphs enabled.
2026-02-06 21:54:41 -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 a8f49bea1e Add sage_attn support to Qwen3-TTS with proper cache invalidation
Implements sage attention (sageattention) for Qwen3-TTS with:
- Auto-detection priority: sage_attn > flash_attention_2 > sdpa > eager
- Post-load attention module patching for sage_attn
- Graceful fallback to sdpa if sage_attn fails
- Proper cache invalidation on attention mode changes

Cache improvements:
- Added attn_implementation to engine instance cache key
- Added attn_implementation to audio cache key generator
- Added x_vector_only_mode to audio cache key (was missing)
- Prevents cache hits when switching attention modes

VRAM management improvements:
- Proactively unload old same-engine model variants before loading new ones
- Prevents VRAM accumulation when changing parameters (attn, dtype, etc.)
- Smart offloading when VRAM pressure detected by ComfyUI

Files changed:
- nodes/engines/qwen3_tts_engine_node.py: Added sage_attn to dropdown
- utils/models/unified_model_interface.py: Sage attention detection & patching
- nodes/unified/tts_text_node.py: Include attn_implementation in cache key
- engines/adapters/qwen3_tts_adapter.py: Pass attn_implementation to cache
- utils/audio/cache.py: Include attn_implementation & x_vector_only in cache
- utils/models/.../model_manager.py: Proactive same-engine variant unloading
2026-01-28 01:13:40 -03:00
diodiogod 273677b8a9 Fix CosyVoice VRAM management and cache invalidation
- Add CosyVoiceWrapper.update_config() to propagate config changes to processor
- Pass use_fp16 parameter to adapter for proper audio cache key generation
- Create CosyVoiceHandler for proper component-level device management
  - Manually moves llm, flow, hift, campplus components to CPU/GPU
  - Properly frees VRAM when unloading (AutoModel lacks .to() method)
- Improve console warning formatting for length mismatch
  - Clean separation of warning from text content
  - Show character counts instead of full text dump

Fixes:
- Cache now invalidates when changing instruction/reference text
- Cache now invalidates when changing use_fp16 setting
- Unload Models button now properly frees ~3GB VRAM from CosyVoice
- Console output is cleaner and more organized
2025-12-29 09:27:54 -03:00
diodiogod 6b89fdc629 Comment out debug quantization check messages 2025-12-09 10:14:37 -03:00
diodiogod c8f7a4759f Fix Step Audio EditX non-quantized model CPU offloading
Fixed CPU offloading for non-quantized (bfloat16/float16/float32) models:

- StepAudioTTS components (llm, cosy_model) don't have .to() method directly
- Handler now moves model.llm and model.cosy_model.cosy_impl individually
- Updates CosyVoice.device tracker when moving cosy_impl to CPU
- Properly handles both raw StepAudioTTS and wrapped models

Fixes unload behavior for non-quantized models to actually free VRAM
instead of silently failing with "no memory freed (model may already be on CPU)"
2025-12-09 01:14:11 -03:00
diodiogod 3887dffb54 Fix Step Audio EditX int8/int4 quantization unload and reload
Multiple critical fixes for bitsandbytes quantized models:

1. **Factory return type**: unified_model_interface now returns raw StepAudioTTS
   instead of wrapped StepAudioEditXEngine to fix tuple unpacking in adapter

2. **Quantization detection**: StepAudioEditXHandler now properly detects
   bitsandbytes int8/int4 models by checking model.llm.modules() for
   Linear8bitLt and Linear4bit classes

3. **Model deletion**: Handler now properly deletes llm, cosy_model, and
   audio_tokenizer components for quantized models that can't use .to()

4. **Cache key differentiation**: Added quantization and torch_dtype to
   tts_text_node cache key so int8/int4 changes create new instances

5. **Dead wrapper detection**: unified_model_interface now checks if cached
   wrapper's model was deleted and forces reload instead of returning dead wrapper

6. **Auto-unload prevention**: Disabled adapter cleanup() auto-unload to keep
   models loaded between generations

7. **Path handling**: Downloader now handles cached filesystem paths without
   KeyError by checking for absolute paths

Fixes:
- Models no longer auto-delete after second generation
- Quantization changes properly trigger model reload
- Manual unload button correctly frees VRAM (2.3GB int4, 3.8GB int8)
- Reload after unload works without "NoneType has no attribute 'frontend'" error
- "local:" prefix resolution now works via downloader pattern
2025-12-09 00:18:21 -03:00
diodiogod b59e6011dd Don't mark int8/int4 models as invalid for reuse
- Removed _is_valid_for_reuse = False
- This was causing auto-unload after every generation
- Int8/int4 models now stay loaded between generations
- Only unload when user explicitly clicks unload button
- Proper behavior: load once, use multiple times, unload when done
2025-12-08 23:26:01 -03:00
diodiogod d1818b2ddc Measure actual VRAM freed for int8/int4 models
- Use torch.cuda.memory_allocated() before and after unload
- Shows real VRAM freed instead of estimated model size
- Print VRAM before → after stats for transparency
- Matches pattern used in model_manager.py
- Users can now see actual VRAM being released
2025-12-08 23:23:11 -03:00
diodiogod 5b660e6e9c Add aggressive cleanup for bitsandbytes int8/int4 unload
- Delete inner _tts_engine and _tokenizer before deleting wrapper
- Mark quantized models as invalid for reuse (can't move back to GPU)
- Run garbage collection 3 times for thorough cleanup
- Reset CUDA peak memory stats
- Double empty_cache calls for aggressive VRAM release
- This should properly free VRAM when unloading int8/int4 models
2025-12-08 23:22:01 -03:00
diodiogod 2812e5c527 Fix quantization detection for Step Audio EditX wrapper
- Check wrapper.quantization attribute for quantization flag
- Check inner _tts_engine.modules() instead of wrapper.modules()
- Fixes 'object has no attribute modules' error
- Properly detects int8/int4 quantization now
2025-12-08 23:15:20 -03:00
diodiogod f6f150f280 Fix Step Audio EditX int8/int4 unload - use handler package system
- Created StepAudioEditXHandler in engine_handlers package
- Detects bitsandbytes quantized models (int8/int4)
- Properly deletes quantized models instead of using .to()
- Forces garbage collection and CUDA cache cleanup
- Registers handler in engine_handlers/__init__.py
- Now properly frees all VRAM when unloading quantized models
2025-12-08 23:11:58 -03:00
diodiogod 7f4f1f10b4 Add Step Audio EditX handler for proper int8 model unloading
- Bitsandbytes int8 models can't use .to() for device movement
- New StepAudioEditXHandler detects quantized models and properly deletes them
- Forces garbage collection and CUDA cache cleanup
- Fixes VRAM not being fully released when using int8 quantization
- Enables switching between int8 and other Step Audio EditX models without memory leaks
2025-12-08 23:05:41 -03:00
diodiogod b9d6f19476 Fix ChatterBox v2 native tags being treated as character names
- Character parser now skips ChatterBox v2 special tokens ([laughter], [giggle], etc)
- These tokens are TTS control tags, not character names
- Warns if user has a character with same name as v2 token
- Fix warning system to trigger for all conflicting tags (not just when both formats present)
- Remove debug print from model manager ensure_device
2025-12-07 08:02:08 -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 a8c62f2307 TIER 3: Complete architecture standardization for model loading
Implement standardized factory infrastructure enabling future engines:

1. ModelLoadConfig dataclass - Single canonical config class for all factories
   - Replaces duplicate UnifiedModelConfig
   - Contains device, model_name, language, model_path, repo_id, additional_params
   - Device resolution in __post_init__ for consistency

2. Engine capability registry - Data-driven engine specifications
   - Defines supports_voice_conversion, multilingual_model_switching, corruption recovery
   - Enables generic error handling without hardcoded engine checks
   - Covers all 7 TTS engines + IndexTTS-2

3. Fallback handler utility - Reusable fallback chain for graceful degradation
   - Try local → download → fallback language pattern
   - Eliminates duplicate fallback code across engines
   - Used by future engines automatically

4. Exception hierarchy - Standardized error types
   - TTSModelLoadingError base class
   - Specific types: NotFoundError, DeviceError, FormatError, InitializationError, LanguageNotSupportedError

Architecture benefits:
- All 8 factories now accept config: ModelLoadConfig instead of **kwargs
- Type-safe, clear factory signatures
- Future engines follow identical pattern
- No deprecated code left behind
- ComfyUI model manager handles both old and new patterns

Testing:
- All 7 TTS engines working correctly
- Device switching and caching working
- No syntax errors, all files compile

Note: SmartModelLoader still in use (Tier 2 cleanup pending) causing benign double-loads on some engines.
2025-11-14 10:10:52 -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 98b167702f Fix Clear VRAM button for all TTS engines after CPU offload
Added comprehensive device management fixes to ensure "Clear VRAM" button
works correctly across multiple generation cycles for all TTS engines.

Changes:
- engines/chatterbox/tts.py: Added .to() method to ChatterboxTTS class
- engines/chatterbox/vc.py: Added .to() method to ChatterboxVC class
- nodes/base/base_node.py: Added device checking before generation that
  reloads models via wrapper system when device mismatch detected
- utils/models/comfyui_model_wrapper/engine_handlers.py: Created missing
  engine handlers file with BaseEngineHandler and HiggsAudioHandler

The fix ensures:
1. Models can be moved between CPU and CUDA via .to() method
2. Device mismatches are detected before generation
3. Models reload through wrapper.model_load() to stay in sync with ComfyUI
4. Wrappers re-register with ComfyUI after reload so Clear VRAM continues working

Tested with ChatterBox Classic and ChatterBox Official 23-Lang - both now
support multiple Clear VRAM cycles without errors.
2025-10-27 21:59:41 -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 d619d38747 Version 4.9.4
Fix VibeVoice garbage collection and auto device detection issues

Technical fixes:
- Add defensive gc import handling to prevent UnboundLocalError crashes
- Implement proper auto device detection for VibeVoice after model unloading
- Fix ComfyUI model wrapper gc.collect() scoping issues
- Improve device persistence for subsequent generations
- References issue #81 VibeVoice garbage collection errors
2025-09-16 19:21:47 -03:00
diodiogod 991be1ca85 Fix IndexTTS-2 device mismatch error after model unload/reload
- Add IndexTTS-2 specific recovery logic in model manager
- Handle device synchronization when model is corrupted after CPU offloading
- Clear cached model config and force device reload for all components
- Add recovery for both normal reuse and force_reload scenarios
- Matches existing patterns used for Higgs Audio and VibeVoice

Fixes: RuntimeError: Expected all tensors to be on the same device,
but got weight is on cpu, different from other tensors on cuda:0
2025-09-16 15:55:35 -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