Nodes/ComfyUI-Fluxtapoz/RF-Edit Forward Sampler
ComfyUI Node Runs on cloud

RF-Edit Forward Sampler

The RF-Edit half that records attention before you change anything

By logtd·Created 2 years ago·Updated 2 years ago· 1,392
RF-Edit Forward Sampler
  • single_layers
  • double_layers
  • SAMPLER
  • ATTN_INJ
save_steps0
order

FlowEditForwardSampler is the "save" half of RF-Edit, the pack's implementation of the RF-Solver-Edit paper ("Taming Rectified Flow for Inversion and Editing"). It walks your image latent forward into noise while recording the attention maps along the way, and hands those maps to the reverse half as an ATTN_INJ bank. The reverse sampler then injects the saved attention back in as it regenerates under a new prompt - which is how RF-Edit keeps the original structure without requiring a full controlled inversion.

How it works

Two things happen on the forward pass. First, over the last save_steps of the walk, the sampler stores the self-attention (keys/values per layer) into an attention bank - the ATTN_INJ you get out. Second, it advances the latent using a second-order scheme: it computes the prediction at the current sigma and at the midpoint, then combines them for a more accurate step. That's the "solver" part of RF-Solver-Edit and it's why the pack gets away with relatively few steps.

The inputs that matter:

  • save_steps (INT, default 0) - how many final steps' worth of attention to record. The more you save, the more structural information the reverse pass can lean on. Set it to at least the number of steps you plan to inject on the other side.
  • single_layers / double_layers - which transformer layers to bank attention from (Flux's single-stream and double-stream blocks). Leave them unconnected and it uses the pack defaults; wire in a FluxAttnOverride or the RFSingle/RFDoubleBlocksOverride nodes if you want to pick specific layers.
  • order - second (default) is the second-order solver, fireflow swaps in the Fireflow fast-inversion scheme. Fireflow is the quicker option if RF-Edit feels slow.

Outputs - read this, it's the confusing part

The node has two outputs: a SAMPLER and an ATTN_INJ. The sampler goes into a SamplerCustomAdvanced; the ATTN_INJ is the bank that must reach the reverse sampler. Because ComfyUI doesn't guarantee execution order between two sibling branches, you route the ATTN_INJ through PrepareAttnBank (which forces ordering) on its way to FlowEditReverseSampler. In the pack's example RF-Edit workflow, the forward and reverse samplers share a flipped-sigmas schedule, with InFluxModelSamplingPred on the forward side and OutFluxModelSamplingPred on the reverse.

Installation

Standard for the pack: ComfyUI Manager → search "ComfyUI-Fluxtapoz" → install → restart, or git clone https://github.com/logtd/ComfyUI-Fluxtapoz into custom_nodes. einshape only, no model downloads.

Common issues

The recurring RF-Edit complaint from people who actually use it: identity drift. When you push a style LoRA through the workflow, faces and likeness tend to shift - users report wanting 90%+ likeness and getting less, and reaching for ControlNet to pin the structure. That's not a bug in this node per se; it's the attention-injection strength being too low. Bump save_steps (and the reverse side's inject_steps to match) so more structure is carried through. Just remember the reverse sampler will refuse to inject more steps than you saved - save_steps sets the ceiling.

Categoryfluxtapoz

Inputs (4)

NameTypeDefaultDescription
save_stepsINT00–18446744073709550000
single_layersoptSINGLE_LAYERS
double_layersoptDOUBLE_LAYERS
orderoptCOMBO2 options: second, fireflow

Outputs (2)

NameTypeDescription
SAMPLERSAMPLER
ATTN_INJATTN_INJ