Nodes/ComfyUI_Fill-Nodes/FL Context Window KSampler
ComfyUI Node

FL Context Window KSampler

Generate video longer than one context window without hand-chaining samplers

By filliptm·Created 3 years ago·Updated a day ago· 630
FL Context Window KSampler
  • model
  • positive
  • negative
  • latent_image
  • vae
  • image
  • model
  • positive
  • negative
  • latent
  • vae
  • image
  • debug_info
seed0
steps20
cfg7.00
sampler_name
scheduler
denoise1.00
context_length81
context_overlap30
context_schedulestandard_static
context_stride1
fuse_methodpyramid
temporal_unitvideo_frames_4n_plus_1
closed_loopfalse
freenoisefalse
causal_window_fixtrue
temporal_dim2
cond_retain_index_list
split_conds_to_windowsfalse

Video diffusion models like Wan are trained on a fixed frame count - 81 frames is the number you'll see over and over in the Wan ecosystem - and asking for more than that in one shot either fails or degrades badly. For a long time the standard workaround was manual: divide your target length into 81-frame segments, hand-calculate the final segment's length against the model's frame-count requirement, track the overlap between segments yourself, and chain samplers. Get any of that arithmetic wrong and you either get a video that's too short or an ending that behaves strangely. By 2026, several independent community projects converged on the same fix - wrap that whole chain-and-restitch loop into one node. FL_KsamplerContextWindow is Fill-Nodes' version of that pattern, built directly on ComfyUI's own comfy.context_windows module rather than reimplementing the windowing logic from scratch.

How it works

Instead of sampling your full latent in one pass, the node walks it in overlapping windows - sample a window, move forward, sample the next window with some frames shared against the previous one for continuity, repeat until the whole sequence is covered, then fuse the overlapping regions back into one continuous result. The context_schedule you pick decides how windows are laid out and advanced (a static grid, a uniform sliding pattern, a looped pattern for content meant to cycle, or fully batched), and fuse_method decides how the overlapping seams between windows get blended back together.

The inputs and outputs that matter

The bulk of the required inputs are the standard sampler set you already know if you've used any KSampler - model, positive, negative, latent_image, seed, steps, cfg, sampler_name, scheduler, denoise. The ones specific to this node, and the ones worth actually understanding before you touch them:

  • context_length (default 81) - how many frames go into a single sampling window. The 81 default isn't arbitrary; it lines up with the frame count Wan's ecosystem is built around.
  • context_overlap (default 30) - how many frames adjacent windows share, which is what gives the fuse step something to blend across instead of producing a visible seam at every window boundary.
  • temporal_unit (video_frames_4n_plus_1 / latent_frames, default video_frames_4n_plus_1) - this names the specific trap that catches people doing this by hand: Wan's VAE compresses time by roughly 4x, so frame counts and latent counts aren't the same number, and only certain frame counts (of the form 4n+1) round-trip cleanly through encode/decode without coming back short. Leaving this on the frame-based default means you think in frames and the node handles the latent-count conversion for you.
  • context_schedule (standard_static / standard_uniform / looped_uniform / batched, default standard_static) - how windows are laid out; looped_uniform is the one to reach for if your output needs to loop seamlessly.
  • fuse_method (pyramid / relative / flat / overlap-linear, default pyramid) - how overlap regions blend; pyramid is a sane default weighting scheme, worth leaving alone until you have a specific seam problem to solve.

The rest - context_stride, closed_loop, freenoise, causal_window_fix (on by default), temporal_dim, cond_retain_index_list, split_conds_to_windows - are expert-tier tuning for specific model architectures and edge cases; the defaults are reasonable starting points and most people won't need to touch them on a first pass.

Optional inputs: vae and image (for an image-conditioned generation path). Outputs are a full passthrough set - model, positive, negative, latent, vae, image - plus debug_info, a STRING worth checking first if a long generation comes back wrong; it's the node's own account of how it windowed your sequence.

How to install it

Ships inside ComfyUI_Fill-Nodes. ComfyUI Manager: search ComfyUI_Fill-Nodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes

then restart. No separate model download for this node - it works with whatever video model you already have loaded; what it needs is a reasonably current ComfyUI, since it depends on comfy.context_windows being present in core.

Common issues & troubleshooting

This manages windowing, not identity drift. It solves the mechanical problem - generate arbitrary length without hand-chaining samplers - but not the harder one: content can still drift across window boundaries the longer a sequence runs. Don't expect a 30-second generation to hold a character's appearance as tightly as an 8-second one just because the windowing is automated.

Frame count matters more than it looks like it should. If you're used to typing an arbitrary target frame count into a video node, this is the one context where that habit bites - some target lengths round-trip cleanly through the VAE and others come back a couple of frames short, because of the 4n+1 requirement. Leaving temporal_unit on the frame-based default is what lets the node absorb that arithmetic for you.

Check debug_info before assuming a bad result is a model problem. This node does meaningfully more bookkeeping than a plain KSampler, so a wrong result is as likely to be a windowing/schedule mismatch as a sampling problem - the debug output is there so you don't have to guess which.

Category🏵️Fill Nodes/Ksamplers

Inputs (24)

NameTypeDefaultDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT7.000–100
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
denoiseFLOAT1.000–1
context_lengthINT811–10000
context_overlapINT300–10000
context_scheduleCOMBOstandard_static4 options: standard_static, standard_uniform, looped_uniform, batched
context_strideINT11–10000
fuse_methodCOMBOpyramid4 options: pyramid, relative, flat, overlap-linear
temporal_unitCOMBOvideo_frames_4n_plus_12 options: video_frames_4n_plus_1, latent_frames
closed_loopBOOLEANfalse
freenoiseBOOLEANfalse
causal_window_fixBOOLEANtrue
temporal_dimINT20–5
cond_retain_index_listSTRING
split_conds_to_windowsBOOLEANfalse
vaeoptVAE
imageoptIMAGE

Outputs (7)

NameTypeDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
latentLATENT
vaeVAE
imageIMAGE
debug_infoSTRING