Commit Graph
13 Commits
Author SHA1 Message Date
diodiogod 08916ea598 Fix MOSS download output and model lifecycle 2026-07-15 21:39:58 -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 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 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 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 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 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