Skip to content

v2.4.2 - DisTorch Purge VRAM V2 — Ollama Toggle

Choose a tag to compare

@ussoewwin ussoewwin released this 16 Jul 03:34
· 44 commits to main since this release
EN 中文

This release adds the Ollama toggle on DisTorch Purge VRAM V2 (DisTorchPurgeVRAMV2), placed below HSWQ, for zero-residual purge of Ollama server VRAM used by comfyui-ollama and comfyui-ollama-describer.

Canonical implementation: repository root purge_vram.py (imported by __init__.py). Fallback nodes/purge_vram.py is kept in sync.


Summary

Item Detail
Node General Purge VRAM V2 — class id DisTorchPurgeVRAMV2
New UI toggle Ollama (below HSWQ)
Target packs comfyui-ollama, comfyui-ollama-describer
Target memory External Ollama server GPU/RAM (not in-process PyTorch models in ComfyUI)
Goal GET /api/ps returns no loaded models after purge

Why this was needed

  1. Ollama models live in the Ollama daemon, not in ComfyUI model_management. Standard ComfyUI unload and DistTorch generic purge do not release them.
  2. comfyui-ollama-describer defaults keep_model_alive=-1, which keeps models loaded indefinitely on the server until explicitly unloaded.
  3. HSWQ purge (v2.4.1) targets HSWQ INT8 / PinCache / kitchen residue — a different failure class from Ollama server state.
  4. Without a dedicated path, operators saw: purge node “done” → Task Manager / nvidia-smi still shows Ollama VRAM → next workflow step conflicts or OOM.

What the Ollama toggle does

When Ollama is enabled on Purge VRAM V2:

1. Discover Ollama server URLs

  • OLLAMA_HOST / OLLAMA_BASE_URL environment variables
  • Module-level constants on loaded comfyui-ollama / comfyui-ollama-describer packages (DEFAULT_URL, url, api_host, …)
  • INPUT_TYPES() defaults on describer node classes (api_host, url)
  • Live ollama.Client instances and Ollama node object fields via gc.get_objects()
  • Fallback: http://127.0.0.1:11434, http://localhost:11434

2. Server-side unload loop (per URL, up to 8 rounds)

For each model name reported by GET /api/ps:

  • POST /api/generate with empty prompt and keep_alive: 0 (and "0")
  • POST /api/chat with empty messages and keep_alive: 0 (and "0")
  • ollama.Client.generate / .chat with the same keep_alive=0 semantics
  • ollama stop <model> CLI when available

Repeat until /api/ps is empty or rounds exhausted. Log FINAL VERIFY OK / FINAL VERIFY FAIL per base URL.

3. Comfy-side state cleanup

  • Clear CHAT_SESSIONS dicts in ollama custom-node modules
  • Reset class-level saved_context on Ollama node classes
  • Delete files under each pack’s saved_context/ directory (preserves .keep)
  • Sweep live Ollama node instances: clear saved_context, messages, context, history, chat_history

4. Completion log

Example summary line:

Ollama: Done — unload_attempts=…, sessions_cleared=…, context_attrs_cleared=…, files_wiped=…, instances_cleared=…, residual=(none)


UI placement

On DisTorchPurgeVRAMV2, enable Ollama together with your other purge toggles as needed. It appears directly under HSWQ in the node UI (see updated screenshot in README).


Related commits (v2.4.1 → v2.4.2)

Hash Change
a69d60d Add Ollama toggle under HSWQ
74b3e4d Deepen purge: describer keep_model_alive=-1, multi-URL harvest, /api/ps verify loop
113fd1a README / zh README / changelog / png/pvram2.png
edde080 Changelog release link for v2.4.2

Requirements

  • Ollama installed and reachable at the harvested URL(s)
  • Custom nodes comfyui-ollama and/or comfyui-ollama-describer if you use them in the workflow
  • Optional: ollama Python package (Client fallback) and ollama CLI on PATH for ollama stop

Upgrade

  1. Update ComfyUI-DistorchMemoryManager to v2.4.2 (or pull main at tag v2.4.2).
  2. Restart ComfyUI (or reload custom nodes) so root purge_vram.py is imported.
  3. In your workflow, open General Purge VRAM V2 and enable Ollama when you use Ollama-based nodes and need server VRAM reclaimed.

Existing workflows without the toggle unchanged; Ollama defaults to off.