VFI Optimizer
The VFI Optimizer that benchmarks your actual GPU so you stop guessing batch_size
- images
- model
- images
- settings
Every pairwise Interpolate node in the Tween pack ships with five memory knobs - batch_size, chunk_size, keep_device, all_on_gpu, clear_cache_after_n_frames - and the README's honest guidance for tuning them is "1 for 8GB, 2–4 for 24GB, 4–16 for 48GB+." That's a decent guess. VFI Optimizer is the node that stops you from guessing: it runs a real calibration on your GPU, at your resolution, with your actual model, and hands back a settings object that wires into any Interpolate or Segment Interpolate node and overrides all five knobs with numbers that actually fit your hardware.
How it works. You drop it inline: it takes the same images and model you'd feed the interpolate node, runs one frame pair through the model once (with peak-memory tracking), and from that measured per-pair VRAM cost plus your total VRAM and system RAM it computes sensible settings - batch size from available headroom, all_on_gpu from whether the output frames would fit, chunk_size from how much system RAM you have, and so on. The calibration is one pair, so it's fast; the node is a benchmark, not a second interpolation.
The inputs:
images- passed straight through, but note the tooltip: only the first 2 frames are used for calibration. Wire the same batch you'll interpolate, since resolution is a big factor.model- any pairwise model: BIM, EMA, SGM, GIMM, SPEED. LDF-VFI uses a different sequence pipeline and isn't supported - the node detects it and returns conservative defaults.min_free_vram_gb(default 2) - VRAM to hold back for ComfyUI, your OS, and the rest of the graph. Higher is safer but slower; 2 is a fine default.force_batch_size(optional, 0 = auto) - if you want to cap the batch at something yourself.
Outputs: settings (the VFI_SETTINGS dict - plug this into any Interpolate node's settings input) and a pass-through images, so you can string Optimizer → Interpolate in one line. The settings input on the interpolate nodes overrides batch_size, chunk_size, keep_device, all_on_gpu, and clear_cache_after_n_frames, so you can leave those widgets alone and let the Optimizer rule.
Install. It's part of the pack - search "Tween" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Ethanfel/ComfyUI-Tween
pip install -r requirements.txt
Restart. No model downloads of its own; it uses whatever loader you wire in.
Where people get burned. Two things. First, the calibration assumes your video's resolution matches the sample you feed it - calibrate with the real footage. Second, it runs a real model inference on load, so don't be alarmed by a few seconds of GPU activity (and if calibration fails for any reason, it returns conservative defaults rather than erroring - that's a feature). Also worth knowing: the settings are computed for one model at one resolution; change resolution or switch to a heavier model and re-run it, or your "optimized" numbers quietly stop being optimal. It's a great tool for the "why is this so slow" post, and it's the rare node that rewards the two minutes it takes to set up.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Input images — only the first 2 frames are used for calibration. | |
| model | * | Any pairwise VFI model (BIM, EMA, SGM, GIMM, SPEED). LDF-VFI uses a separate sequence pipeline. | |
| min_free_vram_gb | FLOAT | 2.00–48 | VRAM to keep free for other tasks (ComfyUI, OS, etc). Higher = safer but slower. |
| force_batch_sizeopt | INT | 00–64 | Override auto-computed batch_size. 0 = auto. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| settings | VFI_SETTINGS | — |