Inverted Pruning
Prune the wrong weights on purpose
- model
- model
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 overgradient_accumulation_steps) to find the weights that matter most for a chosengradient_loss_type(reconstruction,magnitude,perceptual, orvariance), 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_invertedto start;attention_head_removalfor 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model to apply inverted pruning to | |
| pruning_mode | COMBO | magnitude_inverted | Type of inverted pruning to apply |
| threshold | FLOAT | 0.100–0.99 | Percentage of weights to remove (0.1 = remove top 10% most important) |
| target_layers | STRING | all | Comma-separated layer patterns (e.g., 'attention', 'conv', 'mlp') |
| preserve_functionality | FLOAT | 0.00–1 | How much to preserve base functionality (0=pure degradation, 1=mild effect) |
| seed | INT | -1-1–4294967295 | Random seed for reproducible pruning (-1 for random) |
| gradient_accumulation_stepsopt | INT | 11–10 | Number of gradient accumulation steps for more stable importance estimation |
| use_actual_gradientsopt | BOOLEAN | true | Use actual gradient computation (slower but more accurate) or simplified method |
| gradient_loss_typeopt | COMBO | reconstruction | Loss function for gradient computation |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | Model with inverted pruning applied |