MD: Model State Reset (Anti-Static)
When your model goes staticky or glitchy, force it back into eval mode
- model
- clip
- sanitized_model
- sanitized_clip
MD_ModelStateReset is a "have you tried turning it off and on again" node for a model that's misbehaving - static noise, glitchy artifacts, black output, or random OOM errors. It sits between your checkpoint and your KSampler and forces the model back into a known-good state: eval mode on, optional fp32 precision, and an optional full VRAM purge. The display name calls it "Anti-Static," and that's the pitch: if your generation is degrading with static-like noise, this is the first thing to try.
This is squarely aimed at the ACE-Step audio crowd - the author's own field notes describe it as fixing "static degradation and glitchy artifacts in ACE 1.5" - but the mechanism is model-agnostic. Any diffusion model that's picked up a weird state on its way to the sampler can benefit.
How it works
Three independent levers, all applied to a clone of your model:
- enforce_eval - recursively sets
.eval()on the model's components, which disables any dropout or training-mode layers that can inject random noise into sampling. This is the "your model thinks it's still in training" fix, and it's on by default. - force_precision_fp32 - converts the model to 32-bit float, which eliminates fp16 overflow - a classic cause of black/static output. Costs roughly 2x VRAM for weights, so it's off by default and only flipped on when you're seeing artifacts.
- unload_vram - the nuclear option: calls ComfyUI's
unload_all_models()plus a cache purge to clear "ghost" tensors that survive soft clears. Slows the next generation (models reload from RAM) but clears persistent OOM states.
It also accepts an optional clip input and sanitizes that the same way, since conditioning state can accumulate in the text encoder too. Outputs are sanitized_model and sanitized_clip - wire those into your KSampler instead of the originals.
The inputs that matter
- enforce_eval - keep it on; it's the everyday fix.
- force_precision_fp32 - your "I see static/black output" switch. Expect a VRAM cost.
- unload_vram - for persistent OOM or ghost-tensor weirdness.
- debug_mode - set to
1 - Infowhen you first use it; the analytics report tells you what it actually changed, which is the difference between "fixed" and "did nothing and you need to look elsewhere."
Installing
Part of MD Nodes:
cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes
pip install -r requirements.txt
Or ComfyUI Manager → MD Nodes → install → restart. No models to download - it operates on whatever you pass through it.
Common issues
The important caveat is diagnostic honesty: this node fixes state problems, not all problems. If your static/black output is caused by a NaN in the latents, the fix belongs in the NaN Guardian or Latent Sanitizer (both in this pack), not here. Use the debug report to confirm the node changed something - if eval was already on and everything passed through untouched, your glitch has a different root cause, and reaching for fp32 or the VRAM nuke as a shotgun fix just makes everything slower without solving it.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | MODEL INPUT • Purpose: The diffusion model to sanitize. • Requirement: Connect this immediately before your KSampler. | |
| enforce_eval | BOOLEAN | true | FORCE EVAL MODE • Purpose: Recursively sets .eval() on model components. • Effect: Disables Dropout/Training layers that cause noise. • Fixes: 'Static' degradation and 'glitchy' artifacts in ACE 1.5. ⭐ Recommended: Enabled |
| force_precision_fp32 | BOOLEAN | false | FORCE FP32 PRECISION • Purpose: Forces the model to run in 32-bit floating point. • Effect: Fixes 'Static' or 'Black Image' outputs caused by FP16 overflow. • Trade-offs: Uses approx 2x more VRAM for weights. ⭐ Recommended: Disabled (Faster, unless experiencing glitches). |
| unload_vram | BOOLEAN | false | UNLOAD VRAM (THE NUCLEAR OPTION) • Purpose: Forcefully unloads ALL models from GPU memory. • Effect: Clears 'ghost' tensors that survive soft cache clears. • Trade-offs: Slows down generation (must reload model from RAM). ⭐ Recommended: Disabled (Unless you get persistent OOM errors). |
| debug_mode | COMBO | 1 - Info | LOGGING VERBOSITY • Purpose: Controls console output detail level. • Options: 0 (Silent), 1 (Analytics Report), 2 (Full trace). ⭐ Recommended: 1 - Info (to verify fix works). |
| enable_profiling | BOOLEAN | false | PERFORMANCE PROFILING • Purpose: Enable detailed operation timing. • Note: Automatically enabled when debug_mode >= 1. |
| clipopt | CLIP | CLIP INPUT (OPTIONAL) • Purpose: The Text Encoder to sanitize. • Connect this to reset conditioning state accumulation. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| sanitized_model | MODEL | — |
| sanitized_clip | CLIP | — |