Apply To Subset (Bending)
Random-subset bending for partial chaos
- bending_module
- BENDING_MODULE
Full-model bending is dramatic, but it's also blunt - hit every channel and you've changed everything, which is hard to read. This node lets you apply a bending module to only a random slice of the data, so the effect is partial and textured instead of total. It's the difference between dyeing a shirt and tie-dying it.
It wraps an existing BENDING_MODULE in a wrapper that, on each forward pass, picks a random subset and runs the inner module on just that part. The rest of the tensor passes through untouched. Three knobs decide the shape of the chaos:
- percentage - the fraction of the data that gets bent, default
0.5(0 to 1). The useful discovery here: at exactly0or1.0the wrapper is a no-op passthrough. Anything between is a partial bend. - dimension - what you're sampling over:
batch,channel, orspatial. Channel is usually the most interesting - you bend a random subset of the feature channels, which is like selectively messing with certain "concepts" the layer tracks. Spatial randomizes by pixel positions, which reads as noise stippling. Batch selects whole images in a batch. - seed - reproducibility. Same seed, same subset every time, which makes this a genuinely useful ablation tool: you can prove the bend matters by holding the subset constant and toggling the inner module.
The output is still a BENDING_MODULE, so you chain it exactly like any other module: wrap a Rotate Module (Bending) or Add Noise Module (Bending) with this, then inject the result into Model Bending or Model Bending (SD Layers). You can even stack wrappers - bend 50% of channels, then of those... well, you get the idea; the pack is designed for that kind of nesting.
Where this really shines is diagnosis. Instead of asking "does eroding this layer do anything?", ask "does eroding half its channels do anything?" If the answer is yes, the layer's output is load-bearing; if the image barely changes, you found a layer you can abuse freely. That's the low-level tinkering the whole pack is built for.
Install: ComfyUI Manager → search "ComfyUI-Model-Bending" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/abuzreq/ComfyUI-Model-Bending
Dependencies: kornia and scikit-learn.
One thing to know before you invest: the selection is random every forward pass (the seed fixes which subset, but the layer runs many times per generation), so the "subset" isn't stable across denoising steps - it's a different random slice each time. For a fixed, persistent subset you'd want something more structured, which this experimental pack doesn't offer. Fine for exploration, just don't expect surgical stability.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| bending_module | BENDING_MODULE | — | |
| percentage | FLOAT | 0.500–1 | — |
| dimension | COMBO | batch | 3 options: batch, channel, spatial |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BENDING_MODULE | BENDING_MODULE | — |