Skip to content

fix: halve VAE decode tiles on OOM retry instead of jumping to 256px - #2120

Merged
leejet merged 1 commit into
leejet:masterfrom
losewayy:vae-decode-tile-halving
Oct 10, 2026
Merged

leejet merged 1 commit into
leejet:masterfrom
losewayy:vae-decode-tile-halving

Conversation

@losewayy

@losewayy losewayy commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #2108.

prepare_vae_decode_retry_tiling clamps the first spatial-tiling retry to min(size/2, 256 / scale_factor), so the fallback jumps straight to 256px image tiles even when much larger tiles would fit. Removing the clamp makes every retry halve the tile size (1024→512→256…, 1536→768→384…), matching the behavior already used once tiling is enabled and what #2108 asks for.

Each failed attempt only costs a graph build plus a failed workspace allocation, so trying intermediate sizes is cheap compared to running many more small tiles.

Test evidence (RTX 5070 Ti Laptop 12 GB, CUDA, Qwen Image 2.1 Q6_K)

At 1536x1536, decode previously fell back to 121 tiles at 256px in 32.6 s. With progressive halving it lands on 9 tiles at 768px in 10.3 s. For a 1024px decode the first retry is now 512px; #2108's own measurements show 512px tiles decode ~2-4x faster than 256px when they fit.

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted how latent tile sizes are reduced when retrying VAE decoding, allowing retries to use the appropriate smaller tile size.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 018d6d5d-0a3c-4da2-9dcc-e2dbfc308b80

📥 Commits

Reviewing files that changed from the base of the PR and between f89d9b1 and f3d7f70.


📒 Files selected for processing (1)
  • src/core/backend_fit.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.



📝 Walkthrough

Walkthrough

The VAE decode retry now halves the current tile size, with a minimum of 4 and no larger than the current size. It no longer applies a 256-pixel limit when tiling was previously disabled.

Changes

VAE decode retry tiling

Layer / File(s) Summary
Retry tile calculation
src/core/backend_fit.cpp
The retry calculation uses half the current tile size, with a minimum of 4 and a cap at the current size. It removes the prior 256-pixel limit.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: leejet


Merge Risk: ⚪ Minimal · up to f3d7f

VAE decode retries now reduce tile sizes progressively, with existing retry behavior preserved. No actionable merge risk remains.

Architecture Summary

Architecture risk: 🔵 Low · up to f3d7f

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/core/backend_fit.cpp: The smaller-tile calculation no longer limits a first spatial tile to 256 / scale_factor; it now uses half the current size, with a minimum of 4, capped at the current size.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: VAE decode retries now halve tile sizes instead of jumping to 256px.
Description check Passed The description explains the change, references issue #2108, gives technical rationale, and includes concrete test evidence. It does not use the template headings for Related Issue / Discussion or Add…
Linked Issues check Passed Issue #2108 requires VAE decode auto-fit retries to use intermediate tile sizes instead of jumping to the 256-pixel minimum. The change removes the first-retry clamp in `prepare_vae_decode_retry_tilin…
Out of Scope Changes check Passed The whole pull-request diff contains one focused change in src/core/backend_fit.cpp. It only changes VAE decode retry tile-size selection. No unrelated source, API, configuration, or documentation c…

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@leejet
leejet merged commit ce95c09 into leejet:master Oct 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VAE decode auto-fit jumps from 1024 to 256 px tiles, skipping 512 (2-4x slower decode on 16 GB GPUs)

2 participants