From 91947c0b8c795cf504d3848274d4217f0432a324 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 28 Feb 2026 18:56:57 +0100 Subject: [PATCH] Use actual input frame count for all_on_gpu and chunk_size estimates Replace hardcoded 199-frame assumption with 2*N-1 from the actual images input, giving accurate VRAM/RAM estimates for any batch size. Co-Authored-By: Claude Opus 4.6 --- nodes.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nodes.py b/nodes.py index a61eb36..9ef31d3 100644 --- a/nodes.py +++ b/nodes.py @@ -825,11 +825,11 @@ class VFIOptimizer: else: batch_size = max(1, min(int(available_mb * 0.85 / per_pair_vram_mb), 64)) - # all_on_gpu: estimate output frames for 2x on 2 input frames → 3 output - # More generally, estimate if a modest output (e.g. 100 2x-frames) fits + # all_on_gpu: estimate output frames for 2x from actual input count H, W = images.shape[1], images.shape[2] + N = images.shape[0] frame_mb = H * W * 3 * 4 / (1024 ** 2) # float32 [C,H,W] - estimated_output_frames = 199 # 100 input → 199 output at 2x + estimated_output_frames = 2 * N - 1 # 2x is most common multiplier output_vram_mb = estimated_output_frames * frame_mb vram_after_model = total_vram_mb - min_free_mb - model_vram_mb all_on_gpu = output_vram_mb < vram_after_model * 0.5 @@ -844,8 +844,7 @@ class VFIOptimizer: # chunk_size: based on system RAM system_ram_gb = _get_system_ram_gb() system_ram_mb = system_ram_gb * 1024 - # Estimate if full 2x output fits in 60% of RAM - # Conservative: assume 100 input frames worth of output + # Check if full 2x output fits in 60% of RAM if output_vram_mb < system_ram_mb * 0.6: chunk_size = 0 # fits in RAM, no chunking needed else: