Mpi Windowed Sampler
Sample the Video That Won't Fit — One Window at a Time (Refine Only)
- noise
- guider
- sampler
- sigmas
- latent_image
- output
- denoised_output
- info
Video models have a nasty habit: your settings work at one clip length, you add ten frames, and suddenly the card dies. Not bad luck - a video DiT's attention cost scales with T×H×W, so the same sampler that succeeds at one duration OOMs at another with nothing else changed. MpiWindowedSampler is a SamplerCustomAdvanced that samples over overlapping temporal windows and cross-fades the results back together, so a clip too long to refine in one pass still fits. It ships in ComfyUi-MpiNodes, Mad Pony Interactive's big utility pack (the folks behind the Cubric Vision app).
The numbers that motivated it: on MiniMax H3 at 2K on a 16GB card, T=27 samples fine while T=32 and T=37 both die inside comfy_kitchen.prequantize_int8_attention. H3's trained minimum is 124 frames, which is T=37 - the model's shortest legitimate clip is exactly the one a 16GB card can't refine. Lowering the upscale factor doesn't help: stage-2 peak memory is set by the output latent size, not the factor.
The one rule: this is a refine pass
Windowing is unsound for first-pass generation - cut a cold generation into windows and each one will decide its own motion, identity, and framing, and the seams will fight. It works for a refine precisely because the latent arrives already coherent: motion and framing were decided upstream, a short sigma schedule only adds local detail, and two windows have nothing to disagree about. So use it where a hi-res-fix stage 2 goes - a stage-1 latent upscaled to target, low sigmas, adding detail. First-pass through it and you'll get ghosts at every seam.
How the seams disappear
Three decisions make the cross-fade work. Noise is generated once for the whole clip and sliced per window, so both sides of a seam denoise identical noise over identical input - the fade blends two near-identical results instead of two different ones. Windows are cut on the model's temporal grid - H3 packs time as a 2-frame causal head plus blocks of 5, so a legal latent length is 5k+2 and a legal cut point is a multiple of 5; a window ending four frames into a block gets padded and decodes black, an artefact that reads as a seam problem and isn't one. The model stays loaded across windows on purpose: unloading between them would re-stream the whole DiT over PCIe per window, costing more than the sampling it protects.
On an audio-video model (H3, LTXV), the audio in the joint AV latent is sliced to its window for conditioning and restored whole on output - hand a window the entire soundtrack and it thinks frame 15 begins at t=0, so a mouth starts moving two seconds late. The refined audio is discarded and the original stream kept, so nothing stitches a seam into the sound.
The inputs that matter
Wire it exactly like SamplerCustomAdvanced - noise (NOISE), guider (GUIDER), sampler (SAMPLER), sigmas (SIGMAS), latent_image (LATENT) - then three widgets. Both frame widgets count in video frames - the unit an OOM is discovered in; the model's own temporal downscale ratio plus frame_grid do the conversion.
- window_frames (default 90) - a ceiling on the video frames refined at once, not a target. If 124 dies and 90 survives, put 90 here. Windows then shrink to the smallest legal size that covers the clip in the same pass count, so a generous ceiling costs nothing.
- overlap_frames (default 17) - the minimum video frames neighbouring windows share and cross-fade. It costs compute, but skimping invites ghosting: on H3 at T=37, one measured seam went from a face visibly splitting in two, to a trace of distortion at 7 shared frames, to clean at 17 - and 17 is one whole H3 block.
- frame_grid (default 5) - advanced. The model's temporal quantum in latent frames. Leave 5 for H3; set 1 for a model with no temporal packing, which gives plain fixed-size windows. Snapping can only ever hand you more overlap than you asked, never less.
Outputs
- output (LATENT) - the refined, cross-faded latent, audio restored whole.
- denoised_output (LATENT) - the blended x0 prediction, accumulated separately (some graphs, like LTX i2v/t2v, wire it).
- info (STRING) - a report of what was planned: window count, real shared frames, grid, in video and latent units (also printed to the console). Read it once and the grid snapping stops being a mystery.
A clip already at or under the ceiling skips all of this and takes a plain single-pass path, unchanged.
Install & troubleshooting
Same as every node in this pack: install via ComfyUI Manager (search "ComfyUi-MpiNodes"), or manually and restart:
cd ComfyUI/custom_nodes && git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes
No models, no compiled deps - it's all ComfyUI's own sampling API.
- Black frames or flashing at the tail → off-grid window. Keep
frame_gridat 5 for H3; an over-ceiling window risks an OOM, an off-grid one guarantees corruption. - Seam ghosting, a face that doubles → not enough overlap. Raise
overlap_frames- the cross-fade needs to be wide enough to hide two valid-but-different denoisings. - Still OOM → set
window_framesfrom your own card's OOM discovery (124 died, 90 survived → 90). That's the feature.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| noise | NOISE | — | |
| guider | GUIDER | — | |
| sampler | SAMPLER | — | |
| sigmas | SIGMAS | — | |
| latent_image | LATENT | — | |
| window_frames | INT | 901–100000 | CEILING on the VIDEO frames refined at once, not a target. This is the number you discover by hitting an OOM: if 124 frames dies and 90 survives, put 90 here. 90 is what a 16GB card manages for MiniMax H3 at 2K. Windows are then shrunk to the smallest legal size that still covers the clip in the same number of passes, so a generous ceiling costs nothing and a low one costs passes. A clip at or under this length takes the plain single-pass path. |
| overlap_frames | INT | 170–100000 | MINIMUM VIDEO frames neighbouring windows share and cross-fade. Costs compute on every seam. 17 is one whole block for H3. Snapping to the grid can only ever hand you more than you ask for, never less. |
| frame_grid | INT | 51–64 | ADVANCED - the model's temporal quantum, in LATENT frames. Leave it at 5 for MiniMax H3, which packs time as a 2-frame causal head plus blocks of 5; a window off that grid ends in a padded part-block that decodes BLACK. Set 1 for a model with no such structure, which gives plain fixed-size windows and makes the two widgets above count latent frames instead. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output | LATENT | — |
| denoised_output | LATENT | — |
| info | STRING | — |