Commit 4c870cc for stable-diffusion.cpp

commit 4c870cc60cd466427e4802d35a15b681ba9e4e90
Author: losewayy <1134285612@qq.com>
Date:   Sun Oct 25 03:06:58 2026 +0800

    fix: balance singleton tails in short Wan vae decode plans (#2197)

diff --git a/src/model/vae/wan_vae.hpp b/src/model/vae/wan_vae.hpp
index 848427c..6b94bcb 100644
--- a/src/model/vae/wan_vae.hpp
+++ b/src/model/vae/wan_vae.hpp
@@ -1498,6 +1498,16 @@ namespace WAN {
             stateful_config.overlap                 = 0;
             auto plan                               = make_vae_temporal_tile_plan(input.shape()[2], stateful_config);

+            if (sd_version_is_wan(version) && !ae.is_2D && plan.tiles.size() > 1 &&
+                plan.tiles.size() <= 3 && plan.tile_frames > 2 &&
+                plan.tiles.back().end - plan.tiles.back().start == 1) {
+                // Longer plans retain full middle tiles, so balancing their tail cannot shrink the largest decoded output.
+                auto& previous = plan.tiles[plan.tiles.size() - 2];
+                auto& last     = plan.tiles.back();
+                --previous.end;
+                --last.start;
+            }
+
             LOG_VERBOSE("Wan VAE stateful temporal tiling: tile_frames=%d, decode_frames=%d, total latent frames=%lld, tiles=%d",
                         plan.tile_frames,
                         version == VERSION_WAN2_2_TI2V && !ae.is_2D ? config.decode_frames : 1,