fix(loader): force re-run when keep_loaded=False so freed model gets reloaded
ComfyUI caches each node's output keyed by its inputs. With keep_loaded=False, the previous run's Generate node freed the model and processor from the cache (model=None, processor=None on the still-cached MOSS_TTS_MODEL handle). Without IS_CHANGED, ComfyUI hands that empty handle to the next run's Generate, which crashes with 'NoneType has no attribute build_user_message'. Add IS_CHANGED that returns a fresh value (time.time()) when keep_loaded is False, forcing ComfyUI to re-execute load() each run. get_or_load then sees an empty cache and reloads the model from the local HuggingFace cache. For keep_loaded=True the return value is stable, so ComfyUI keeps reusing the same loaded model — preserves the original keep-resident behaviour.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""ComfyUI node: MOSSTTSLoader."""
|
||||
|
||||
import time
|
||||
|
||||
from ..lib.model_state import get_or_load
|
||||
|
||||
|
||||
@@ -27,6 +29,16 @@ class MOSSTTSLoader:
|
||||
FUNCTION = "load"
|
||||
CATEGORY = "MOSS-TTS/loaders"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, model_id, device, dtype, attn_implementation, keep_loaded):
|
||||
# When keep_loaded is False, the previous run's Generate node freed the
|
||||
# model from the cache. ComfyUI's per-node output cache would otherwise
|
||||
# hand the now-empty handle to Generate again. Returning a fresh value
|
||||
# each call forces ComfyUI to re-execute load() and reload the model.
|
||||
if not keep_loaded:
|
||||
return time.time()
|
||||
return f"{model_id}|{device}|{dtype}|{attn_implementation}|keep"
|
||||
|
||||
def load(self, model_id, device, dtype, attn_implementation, keep_loaded):
|
||||
entry = get_or_load(
|
||||
model_id=model_id,
|
||||
|
||||
Reference in New Issue
Block a user