ComfyUI Node

Network Bending

The 'break it on purpose' node that started this pack

By DavidPiazza·Created about a year ago·Updated 9 months ago· 0
Network Bending
  • model
  • model_b
  • model
operationadd_noise
intensity0.10
target_layersall
seed-1
mix_ratio0.50

This is the flagship - the node the whole pack is named after. Network Bending takes a loaded checkpoint and deliberately corrupts its weights in one of six ways, in memory, before you sample. The idea, which comes from real research on "bending" neural networks to see what breaks and how, is that a model's failures are as interesting as its successes. Add a little noise to a model's weights and "photorealistic portrait" becomes "photorealistic portrait by a painter with a tremor." Push further and you're in full glitch territory. It's an art tool, not a performance tool.

How it works

The node clones the model (your original stays untouched), then applies one operation to the weights:

  • add_noise - injects Gaussian noise scaled to each weight tensor's own standard deviation. The gentlest, most controllable bend; the default.
  • scale_weights - multiplies weights by a factor mapped from intensity (0–1 becomes 0–2×). Below 0.5 dampens, above 0.5 amplifies.
  • prune_weights - zeroes out the smallest weights, sparsifying the layer.
  • randomize_weights - replaces a fraction of weights with fresh random values.
  • smooth_weights - spatially blurs weight matrices (a real 3×3 kernel for 2D weights), which smears the model's "thinking" rather than breaking it.
  • quantize_weights - snaps weights to discrete levels; fewer levels (low intensity) is more destructive.

intensity (0–1) is your dial, and target_layers is your scalpel: comma-separated patterns like conv, attention, mlp restrict the operation to layers whose names match, so you can corrupt only the attention blocks or only the downsampling convs. seed makes the damage reproducible - set it, find a good one, keep it.

There's also a model_b + mix_ratio optional pair for "mixing operations," which routes you toward the pack's model-blending functionality. Keep it simple on your first run: single model, add_noise, low intensity.

Output is the bent MODEL, straight into the KSampler. A nice touch: the node sends a network_bending.feedback event to the UI telling you how many layers it modified, which is genuinely useful when target_layers didn't match anything.

The inputs that matter

  • model - the checkpoint to modify (from any checkpoint/diffusion loader).
  • operation - the six bends above; add_noise to start.
  • intensity - the amount, 0–1.
  • target_layers - which layers take the hit; all by default.
  • seed - reproducibility.

Installing it

The pack is DavidPiazza/network_bending. ComfyUI Manager (search "Network Bending") or:

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

Restart. No pip step - the core nodes are dependency-light and the pack loads its own src/.

Gotchas

The big one is target_layers string matching: if your model names layers like model.diffusion_model.input_blocks, a pattern of input works, but conv_in will only match if that substring literally appears. When nothing matches, you get a clone with zero modified layers and a feedback message that tells you exactly that - so read the toast. Also, remember every bend here is in-memory and per-run: it doesn't write to disk, which is great for experimenting and means you reapply it every queue run. And a pack-wide note: at 0.0.1, not every dropdown in this pack is fully wired - but this node, the one that matters most, is genuinely real.

Categorynetwork_bending

Inputs (7)

NameTypeDefaultDescription
modelMODELThe model checkpoint to modify
operationCOMBOadd_noiseThe type of network bending operation to perform
intensityFLOAT0.100–1Strength of the operation (0-1)
target_layersSTRINGallComma-separated layer names or patterns to target (e.g., 'conv', 'attention')
seedINT-1-1–4294967295Random seed for reproducible results (-1 for random)
model_boptMODELSecond model for mixing operations
mix_ratiooptFLOAT0.500–1Mix ratio when blending two models (0=model_a, 1=model_b)

Outputs (1)

NameTypeDescription
modelMODELModified model with network bending applied