MMnode/utils/model_memory.py
Z User 27041a8a9f feat: scrub EasyMedia/MiniMax branding from all user-facing output
Console, errors, tooltips, descriptions and display names no longer
reveal the pack heritage or the underlying model family:

- [EasyMedia]/[Easy Media] console prefixes -> [Moxie] (11 files)
- New console privacy filter (utils/log.py, installed at pack import):
  rewrites MiniMax variants in every displayed logging record, including
  ComfyUI core lines like 'Model MiniMaxH3 prepared for dynamic VRAM
  loading', %-args and matching tracebacks. api.minimaxi.com is protected
  so cloud-API errors stay accurate.
- Node display names rebranded (node_ids untouched, workflows safe):
  'MiniMax H3 To Video' -> 'Moxie To Video', etc.
- ~40 error/tooltip/description strings reworded to Moxie terms.
- CLIP error no longer names CLIPType.MINIMAX; test match updated.

Unchanged on purpose (breaking if touched): node_ids/class names,
combo value 'MiniMax' (workflow payloads), internal dict keys
(minimax_keyframes/minimax_refs), llm_api cloud provider strings,
class-name logic checks, source-only docstrings.
2026-09-26 23:05:24 +00:00

52 lines
1.6 KiB
Python

from __future__ import annotations
import gc
from typing import Any
def _move_model_to_cpu(model: Any) -> None:
if model is None:
return
cpu = getattr(model, "cpu", None)
if callable(cpu):
try:
cpu()
return
except Exception as error:
print(f"[Moxie] Failed to move model to CPU with cpu(): {error}")
to = getattr(model, "to", None)
if callable(to):
try:
to("cpu")
except Exception as error:
print(f"[Moxie] Failed to move model to CPU with to('cpu'): {error}")
def cleanup_model_memory(*models: Any) -> None:
"""Release model references and clear accelerator allocator caches."""
for model in models:
_move_model_to_cpu(model)
gc.collect()
try:
import torch # type: ignore[import]
except ImportError:
return
try:
if torch.cuda.is_available():
torch.cuda.empty_cache()
ipc_collect = getattr(torch.cuda, "ipc_collect", None)
if callable(ipc_collect):
ipc_collect()
except Exception as error:
print(f"[Moxie] Failed to clear CUDA cache: {error}")
try:
mps_backend = getattr(getattr(torch, "backends", None), "mps", None)
if mps_backend is None or not mps_backend.is_available():
return
mps = getattr(torch, "mps", None)
empty_cache = getattr(mps, "empty_cache", None)
if callable(empty_cache):
empty_cache()
except Exception as error:
print(f"[Moxie] Failed to clear MPS cache: {error}")