FL Context Window KSampler
Generate video longer than one context window without hand-chaining samplers
- model
- positive
- negative
- latent_image
- vae
- image
- model
- positive
- negative
- latent
- vae
- image
- debug_info
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, defaultvideo_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, defaultstandard_static) - how windows are laid out;looped_uniformis the one to reach for if your output needs to loop seamlessly.fuse_method(pyramid/relative/flat/overlap-linear, defaultpyramid) - how overlap regions blend;pyramidis 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.
Inputs (24)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 7.000–100 | — |
| sampler_name | COMBO | 44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| denoise | FLOAT | 1.000–1 | — |
| context_length | INT | 811–10000 | — |
| context_overlap | INT | 300–10000 | — |
| context_schedule | COMBO | standard_static | 4 options: standard_static, standard_uniform, looped_uniform, batched |
| context_stride | INT | 11–10000 | — |
| fuse_method | COMBO | pyramid | 4 options: pyramid, relative, flat, overlap-linear |
| temporal_unit | COMBO | video_frames_4n_plus_1 | 2 options: video_frames_4n_plus_1, latent_frames |
| closed_loop | BOOLEAN | false | — |
| freenoise | BOOLEAN | false | — |
| causal_window_fix | BOOLEAN | true | — |
| temporal_dim | INT | 20–5 | — |
| cond_retain_index_list | STRING | — | |
| split_conds_to_windows | BOOLEAN | false | — |
| vaeopt | VAE | — | |
| imageopt | IMAGE | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| latent | LATENT | — |
| vae | VAE | — |
| image | IMAGE | — |
| debug_info | STRING | — |