- 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
29 lines
961 B
Python
29 lines
961 B
Python
"""
|
|
Cache utilities for ComfyUI model wrapper system
|
|
"""
|
|
|
|
import time
|
|
|
|
# Global cache invalidation flag to force recreation of all engine instances
|
|
# When models are unloaded, this timestamp is updated to invalidate all node caches
|
|
_global_cache_invalidation_flag = 0.0
|
|
|
|
|
|
def is_engine_cache_valid(cache_timestamp: float) -> bool:
|
|
"""
|
|
Check if an engine cache is still valid based on global invalidation flag.
|
|
|
|
Args:
|
|
cache_timestamp: When the cache entry was created
|
|
|
|
Returns:
|
|
True if cache is still valid, False if it should be invalidated
|
|
"""
|
|
return cache_timestamp > _global_cache_invalidation_flag
|
|
|
|
|
|
def invalidate_all_caches():
|
|
"""Set global cache invalidation flag to force engine recreation"""
|
|
global _global_cache_invalidation_flag
|
|
_global_cache_invalidation_flag = time.time()
|
|
print(f"🗑️ Set global cache invalidation flag to force engine recreation") |