Nodes/molbals-stats/molbals-stats
ComfyUI Node

molbals-stats

Your generation's real memory bill — peak VRAM, peak RAM, and wall time, without guessing

By molbal·Created 2 months ago·Updated 2 months ago· 1
molbals-stats
  • trigger
  • stats_json
  • peak_vram_mb
  • peak_ram_mb
  • total_seconds

Every "why is my VRAM pegged" thread ends the same way: someone tells you to watch Task Manager, and you sit there squinting at a number that resets the moment the graph reruns. MolbalsStats (from the molbals-stats pack) is the fix for that. Drop it at the end of a workflow, connect it to your final image or latent, and when the prompt finishes you get the honest answer: elapsed seconds, peak process RAM, and peak VRAM - not the live ticker, but the actual peak your render touched.

It's one node, no models, no API key, nothing to configure. If you've ever wondered whether an SDXL workflow actually fits in 8 GB or whether a Flux GGUF really runs at the Q4 you think it does, this is the quickest way to find out.

How it works

The trick is timing. MolbalsStats registers a ComfyUI cache-provider hook that fires when a prompt starts, then spawns a background thread that samples every 0.05 seconds while the prompt runs. Each sample reads two things: your ComfyUI process's RSS (via psutil, the pack's only real dependency) for peak RAM, and the active torch device's memory for VRAM. On CUDA it reads torch.cuda.mem_get_info - free vs. total - so you're seeing actual device memory in use during the render, not just the tensors ComfyUI happens to track. On CPU or MPS it just reports RAM, since there's no VRAM to measure.

Crucially, the node's IS_CHANGED method returns float("NaN"), which is the ComfyUI idiom that forces a node to run every single time. That's what keeps it from replaying a cached snapshot from a previous prompt - you always get fresh numbers for the run you just did. The one cost of that trick is real: an always-dirty node defeats caching for everything behind it. This one sits at the very end of the graph as an output node, so the blast radius is small, but don't leave it in a workflow you're running at production speed.

Inputs and outputs that matter

There's exactly one input, and its value is never actually used:

  • trigger - a wildcard (*) socket. Connect your final decoded image or latent here; the node waits for that value to be produced before it reads the stats. Think of it as a "wait until the generation is done" handshake, not data.

And four outputs:

  • stats_json (STRING) - the full payload as pretty-printed JSON: prompt_id, device, total_seconds, peak_vram_mb, peak_ram_mb, the deltas versus the prompt's baseline, and the sample count. The single most useful output to look at.
  • peak_vram_mb (FLOAT), peak_ram_mb (FLOAT), total_seconds (FLOAT) - the same numbers split out so you can wire them into a text node, a plotter, or a comparison branch.

Where people get burned: if a value couldn't be measured - say, VRAM on a CPU-only box - the numeric outputs return -1.0 instead of a real number. -1 is "not available," not "zero VRAM."

Installing it

If you use ComfyUI Manager, search "molbals-stats" and hit install. Otherwise:

cd ComfyUI/custom_nodes
git clone https://github.com/molbal/ComfyUI-molbals-stats

Then restart ComfyUI. The only dependency is psutil, which installs automatically - there are no model downloads and nothing heavy. The pack is MIT-licensed, and the same author (molbal) maintains a well-known GGUF fork in the ComfyUI scene, which is a decent sign this won't be abandoned next week.

Troubleshooting

The main gotchas are the boring, real ones:

  • Numeric outputs show -1.0 - you're on a device where VRAM can't be sampled, or the session didn't attach. Check stats_json for the full picture.
  • The JSON says "Restart ComfyUI after installing the node" - the lifecycle hook hasn't registered, which after a fresh install is expected. Restart and rerun.
  • Node doesn't appear in the menu after install - the __init__.py silently registers nothing if it can't import ComfyUI internals, so update ComfyUI first and restart again.

One honest caveat: the RAM number is your whole ComfyUI process's RSS peak, not a clean per-prompt delta. The JSON's peak_ram_delta_mb (peak minus the baseline at prompt start) is the closest thing to a per-render number, so lean on that when comparing workflows. For a "how much did that actually cost" answer in one glance, it's hard to beat.

Categoryutils/diagnostics

Inputs (1)

NameTypeDefaultDescription
trigger*Connect this to the final generated value you want to wait for before reading stats.

Outputs (4)

NameTypeDescription
stats_jsonSTRING
peak_vram_mbFLOAT
peak_ram_mbFLOAT
total_secondsFLOAT