Nodes/RES4LYF/LayerPatcher
ComfyUI Node Runs on cloud

LayerPatcher

Patch specific transformer layers of a model at high precision

By ClownsharkBatwing·Created 2 years ago·Updated 17 days ago· 1,222
LayerPatcher
  • model
  • model
embedder
gates
last_layer
dtypefloat64

LayerPatcher is a model-surgery node. It reaches into a diffusion model and patches specific pieces of it - an embedder, a set of gates, a last layer - running the patched computation at a precision you choose. This is advanced, experimental territory, and RES4LYF is upfront that a lot of the pack "remains experimental and is subject to further changes." LayerPatcher is one of those pieces.

You wouldn't reach for this to make a prettier image in a normal workflow. It's the kind of node that exists so the pack's more exotic features - precision-sensitive sampling, style operations, layer-level interventions - have a way to modify targeted parts of a transformer without rebuilding the whole model. The dtype default of float64 is the pack's fingerprint again: RES4LYF does a surprising amount of its work in double precision for numerical accuracy, and this patcher lets you run the affected layers there.

How it works

You pass a model in, choose which components to patch (the embedder, gates, and last-layer dropdowns are populated from the loaded model, so the choices depend on what architecture you've connected), pick the dtype, and get a patched model out. The empty option lists in the schema are the giveaway that this node introspects your specific model rather than offering a fixed menu.

The inputs and outputs that matter

  • model (MODEL) - the model to operate on.
  • embedder, gates, last_layer - the targets, drawn from the connected model's actual structure. These are populated at runtime, so if they're empty, you haven't wired a compatible model in yet.
  • dtype (default float64; also bfloat16, float16, float32) - the precision the patched layers compute at. float64 is exact and heavy; lower precision is lighter on VRAM and faster.

Output is the patched model (MODEL), which flows on to your sampler.

How to install it

Comes with RES4LYF. ComfyUI Manager: search RES4LYF, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

Portable builds use the embedded pip. Restart, hard-refresh (F5).

Common issues

Be honest with yourself about whether you need this. It's a surgical tool with almost no beginner-facing documentation - if you're not already following a specific RES4LYF workflow that calls for it, dropping it into a graph blind is more likely to break things than improve them. The empty target dropdowns confuse people: they fill in only once a compatible model is connected, so "there are no options" usually means "connect the model first" (or "this architecture isn't one the patcher targets"). And the float64 default can tank speed on GPUs that are slow at double precision - if a workflow using this node crawls, that's the first dial to drop to float32. Treat it as experimental, because the author does.

CategoryRES4LYF/patchers

Inputs (5)

NameTypeDefaultDescription
modelMODEL
embedderCOMBO0 options:
gatesCOMBO0 options:
last_layerCOMBO0 options:
dtypeCOMBOfloat644 options: bfloat16, float16, float32, float64

Outputs (1)

NameTypeDescription
modelMODEL