ComfyUI Node

Inverted Pruning

Prune the wrong weights on purpose

By DavidPiazza·Created about a year ago·Updated 9 months ago· 0
Inverted Pruning
  • model
  • model
pruning_modemagnitude_inverted
threshold0.10
target_layersall
preserve_functionality0.0
seed-1
gradient_accumulation_steps1
use_actual_gradientstrue
gradient_loss_typereconstruction

Normal pruning is a performance trick: cut the least important weights, keep the model working. Inverted Pruning does the opposite on purpose - it removes the most important weights, because "artistically broken" is a look. This is the node you reach for when you want a model to start glitching in interesting ways: faces that smear, compositions that fall apart in the middle, that whole corrupted-network aesthetic, tuned by how much damage you actually want.

How it works

The source docstring calls it the inverted Lottery Ticket Hypothesis, and that's the vibe: instead of keeping the winning tickets, you torch them. The node clones your model in memory, then removes a percentage of weights based on the pruning_mode you pick:

  • magnitude_inverted - deletes the highest-magnitude weights (the ones doing the most work). The default, and the one that breaks things most coherently.
  • structured_inverted - removes weights in structured blocks rather than individually.
  • attention_head_removal - knocks out whole attention heads; this is the mode that turns prompt adherence into a suggestion.
  • channel_pruning_inverted - drops channels instead of individual weights.
  • gradient_based_inverted - actually computes gradients (optionally accumulated over gradient_accumulation_steps) to find the weights that matter most for a chosen gradient_loss_type (reconstruction, magnitude, perceptual, or variance), then removes those. Slower, but the damage lands where it's most visible.

threshold is the dial - 0.1 means "remove the top 10% most important." Read that tooltip twice: this isn't the standard pruning threshold, it's the inverse; higher is more destructive. preserve_functionality (0–1) is your safety knob: 0 is pure degradation, 1 is a mild tickle. target_layers lets you confine the damage to attention, conv, mlp, or whatever substring pattern matches your model's layer names - comma-separated, all for everything.

The inputs that matter

  • model - the checkpoint you want to degrade.
  • pruning_mode - magnitude_inverted to start; attention_head_removal for targeted weirdness.
  • threshold - how much of the "important" weight budget gets deleted.
  • preserve_functionality - your guardrail between "glitch" and "static."
  • seed - set it so your favorite flavor of broken is reproducible.

Output is a MODEL, straight into the KSampler.

Installing it

From the DavidPiazza/network_bending pack - ComfyUI Manager (search "Network Bending") or:

cd ComfyUI/custom_nodes
git clone https://github.com/DavidPiazza/network_bending.git

Restart. No extra pip deps for the core nodes; the pack loads its own src/ itself.

Gotchas

Start with a model you can afford to ruin - this node genuinely ruins models, that's the job - and render at low intensity first. The gradient modes default to use_actual_gradients = true, which is meaningfully slower than the simplified method; if you're iterating on an effect, flip it off and only turn it on for the final pass. One more warning that applies to the whole pack: it's version 0.0.1 and a few of its sibling nodes ship as stubs, but Inverted Pruning is fully implemented - the dropdowns aren't lying here. The most common real-world mistake is just cranking threshold to 0.9, which isn't a glitch aesthetic, it's a broken checkpoint.

Categorynetwork_bending

Inputs (9)

NameTypeDefaultDescription
modelMODELThe model to apply inverted pruning to
pruning_modeCOMBOmagnitude_invertedType of inverted pruning to apply
thresholdFLOAT0.100–0.99Percentage of weights to remove (0.1 = remove top 10% most important)
target_layersSTRINGallComma-separated layer patterns (e.g., 'attention', 'conv', 'mlp')
preserve_functionalityFLOAT0.00–1How much to preserve base functionality (0=pure degradation, 1=mild effect)
seedINT-1-1–4294967295Random seed for reproducible pruning (-1 for random)
gradient_accumulation_stepsoptINT11–10Number of gradient accumulation steps for more stable importance estimation
use_actual_gradientsoptBOOLEANtrueUse actual gradient computation (slower but more accurate) or simplified method
gradient_loss_typeoptCOMBOreconstructionLoss function for gradient computation

Outputs (1)

NameTypeDescription
modelMODELModel with inverted pruning applied