Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/backend_fit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ namespace sd::backend_fit {
retry_mode = tiling_params.enabled ? "spatial+temporal" : "temporal";
} else if (!tiling_params.enabled) {
tiling_params.enabled = true;
// 512px VAE decode memory fix: get_tile_sizes() defaults to
// rel_size=1.0 (factor branch wins), which yields a full-size tile
// (tiling effectively disabled) and can exceed device buffer limits
// (Adreno 740: 512px decode graph ~1.94GB). Half-relative tiles make
// tiling effective (~416MB), no quality impact (VAE tiling overlaps).
tiling_params.rel_size_x = 0.5f;
tiling_params.rel_size_y = 0.5f;
if (tiling_params.tile_size_x <= 0) {
tiling_params.tile_size_x = 256;
}
Expand Down
5 changes: 4 additions & 1 deletion src/stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3085,8 +3085,11 @@ class StableDiffusionGGML {
auto latents = first_stage_model->diffusion_to_vae_latents(x);
auto decoded = first_stage_model->decode(n_threads, latents, vae_tiling_params, decode_video, circular_x, circular_y);
const bool prefer_temporal_tiling = decode_video && first_stage_model->can_temporal_tile_decode();
// 512px VAE decode memory fix: retry with tiling unconditionally on
// decode failure (OOM) instead of gating on --auto-fit (default off),
// so mobile GPUs with small buffers recover automatically. Only fires
// when decode actually failed, no side effects on the happy path.
while (decoded.empty() &&
auto_fit_enabled &&
sd::backend_fit::prepare_vae_decode_retry_tiling(vae_tiling_params, prefer_temporal_tiling)) {
first_stage_model->free_compute_buffer();
decoded = first_stage_model->decode(n_threads, latents, vae_tiling_params, decode_video, circular_x, circular_y);
Expand Down