KSampler (Flatten)
The KSampler that actually runs FLATTEN — where your edit comes out
- model
- trajectories
- positive
- negative
- latent_image
- injections
- LATENT
The sampler the whole pack was built around
KSampler (Flatten) is where the edit actually happens. The rest of ComfyUI-FLATTEN feeds it: the Unsampler runs your input video backwards to noise and captures injection features, Sample Trajectories reads the optical flow, and this node runs the noisy latent forward again - with the injections and trajectories steering every denoise step - to produce the edited frames. It looks like a stock KSampler with extra knobs, and mostly it is, except those extra knobs are the entire point.
The core mechanism is feature injection: the Unsampler recorded intermediate features from your input frames, and this sampler replays them into the model's 3D UNet for the first injection_steps of the schedule. That's what pins the output to your original footage instead of letting it drift into a new, unrelated video. The old_qk toggle then chooses which FLATTEN attention variant runs - the README's two recipes are built entirely around it.
The knobs that matter
- model - from Load Checkpoint with FLATTEN model. A regular loader's model won't work here.
- injections - the
INJECTIONSoutput of the Unsampler (Flatten). Required. - trajectories - from Sample Trajectories, sampled at the same resolution as the latent.
- injection_steps - how many steps the injection features stay active (default 8, with
stepsdefaulting to 10). - old_qk -
0or1.0is the video-editing recipe;1is the scene-editing one. - add_noise / noise_seed - leave
add_noiseoff unless you're deliberately doing the experimental path.
Everything else - cfg (8), sampler_name, scheduler, positive/negative, start_at_step, end_at_step, return_with_leftover_noise, latent_image - works like a normal KSampler. Output is one LATENT, ready for VAEDecode.
Two recipes, straight from the README
Video editing (recommended). Unsampler on euler, this node on dpmpp_2m, old_qk = 0 on both, and add_noise off. Don't use other samplers - the author is explicit that other samplers or add_noise will wreck temporal consistency. If you add IP-Adapter for style, expect to fine-tune it; it struggles without extra noise.
Scene editing (experimental). Use LCM on the KSampler (not the Unsampler), old_qk = 1, and ancestral samplers work well here. You can experiment with add_noise when the sampler injects its own noise. IP-Adapter actually helps guide these toward a specific look. Expect some consistency loss and worse behavior on high-motion scenes - it's flagged experimental for a reason.
Gotchas
Batching a lot of frames degrades consistency - the author is candid that the current batching mechanism has this limit, and the fix is pending. Also remember the model contract: only the FLATTEN checkpoint loader's model belongs in this node.
Installing
Search ComfyUI-FLATTEN in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/logtd/ComfyUI-FLATTEN
Restart ComfyUI. No extra Python packages - requirements.txt is empty, and everything rides on ComfyUI's own torch/torchvision. For batching you'll also want Kosinkadink's ComfyUI-AnimateDiff-Evolved, which the pack's example workflow uses for context windows.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| add_noise | COMBO | 2 options: disable, enable | |
| noise_seed | INT | 00–18446744073709550000 | — |
| steps | INT | 101–10000 | — |
| injection_steps | INT | 80–10000 | — |
| old_qk | INT | 00–1 | — |
| trajectories | TRAJECTORY | — | |
| cfg | FLOAT | 8.00–100 | — |
| sampler_name | COMBO | 27 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +21 | |
| scheduler | COMBO | 6 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | — | |
| injections | INJECTIONS | — | |
| start_at_step | INT | 00–10000 | — |
| end_at_step | INT | 100000–10000 | — |
| return_with_leftover_noise | COMBO | 2 options: disable, enable |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |