[GH-ISSUE #3792] [Images] HIP backend: Qwen-Image-2.1-Turbo VAE decode runs out of memory from 1536x1024 upwards (--vae-tiling fixes it) #1598

Closed
opened 2026-11-04 01:52:31 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @lbbit on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3792

Area

Engine (image generation)

Desktop app, Terminal or source?

Source build. Strata 0.1.45, serve/server.py, Linux. The image job runs engine-image/sd-cli (stable-diffusion.cpp) with Qwen-Image-2.1-Turbo.

What happened

POST /v1/images/generations with size=1536x1024 fails; 1024x1024 works.

The service reports:

[strata] image: 1536x1024, n=1, 8 steps, seed 205380810
[strata] image job failed: sd-cli exited with code -6
#10 ... in GGMLRunner::execute_graph(...)
#12 ... in WAN::WanVAERunner::_compute(int, sd::Tensor<float> const&, bool) ()
#13 ... in VAE::compute_with_temporal_tiling(...)
#14 ... in VAE::decode(...)
#16 ... in StableDiffusionGGML::decode_first_stage(...)

Running sd-cli directly with the same arguments shows the real error above the backtrace:

[E] ggml: ROCm error: out of memory
[E] ggml:   current device: 0, in function alloc at ggml/src/ggml-cuda/ggml-cuda.cu:510
[3]  ggml_cuda_error(...)
[4]  ggml_cuda_pool_leg::alloc(unsigned long, unsigned long*) ()
[5]  ggml_cuda_mul_mat_cublas(...)
[12] WAN::WanVAERunner::_compute(...)
[13] VAE::compute_with_temporal_tiling(...)
[16] StableDiffusionGGML::decode_first_stage(...)

So the crash is not in the sampling step: sampling completes, and the abort happens in the VAE decode, when the latent is expanded into pixels and a large contiguous allocation fails.

The failure is not caused by the text model holding VRAM: it reproduces with the engine unloaded and both cards completely free (VRAM 0%).

Why 1024x1024 works and 1536x1024 does not

The VAE decode peak allocation grows with the pixel count. On one 24 GB card, with the three model files (7.6 GB Q8_0 denoiser + 5.1 GB Qwen3-VL-8B conditioner + 0.7 GB VAE) resident in VRAM, the decode has roughly 10 GB left, which is enough for 1024x1024 but not for 1536x1024.

Measured with the same model on one card (engine unloaded, both cards idle):

size without --vae-tiling with --vae-tiling
1024x1024 OK OK
1536x1024 out of memory OK (35.9 s)
1536x1536 out of memory OK (57.7 s)
2048x1024 out of memory OK (50.1 s)
2048x2048 out of memory OK (135.3 s)

--vae-tiling (256x256 tiles) fixes every size; the images have no visible seams.

Suggested fix

Add --vae-tiling to the sd-cli arguments that tools/image/install.py writes, the same way the Vulkan setup already does it. docs/IMAGES.md says:

On Vulkan setup adds --vae-tiling --vae-tile-overlap 0.25: an untiled 1024x1024 VAE decode on a Radeon 780M is one GPU job long enough to trip the kernel driver's job timeout (no image)

The HIP backend gets no such automatic flag, so on a 24 GB RDNA3 card the Qwen-Image-2.1-Turbo VAE decode runs out of memory from 1536x1024 upwards. It looks like the tiling (and the tile overlap) should be added for the HIP backend as well, or at least that the setup should warn when the planned resolution does not fit.

Note that need_mib in serve/images.py (models + 2 GiB + 4 GiB per megapixel) underestimates the VAE decode peak, so 1536x1024 passes the planning check and then fails in the job. The formula or the check may want the decode peak too.

Smallest steps or command that reproduce it

M=/path/to/qwen-image-2.1-turbo
./engine-image/sd-cli \
  --diffusion-model $M/qwen-image-2.1-turbo-Q8_0.gguf \
  --vae $M/qwen_image_2.1_vae_bf16.safetensors \
  --llm $M/Qwen3-VL-8B-Instruct-UD-Q4_K_XL.gguf \
  -p "a serene mountain lake at sunset" --steps 8 --cfg-scale 1.0 \
  --sampling-method euler \
  --sigmas "1.0,0.978453,0.95418,0.926626,0.89508,0.845148,0.704534,0.414568,0.0" \
  -W 1536 -H 1024 -s 42 -o /tmp/out_%03d.png --diffusion-fa

Exit code 134 (SIGABRT) with the out-of-memory error above. Adding --vae-tiling makes it succeed.

Environment

  • GPU: 2x AMD Radeon RX 7900 XTX 24 GB (gfx1100, Navi 31), ROCm 7.2.4, backend: hip
  • Kernel 6.8.0, Ubuntu 22.04
  • Model: Qwen-Image-2.1-Turbo Q8_0, 8 steps, CFG 1, euler, Turbo's own sigmas
  • stable-diffusion.cpp 2988060a4338a5dcd94721c964a8e87003c1ac8b, ggml d25b121ce1d6ae0c7e62ad080460d9fc1e46dd93
  • Strata 0.1.45, source build, HIP
Originally created by @lbbit on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3792 ### Area Engine (image generation) ### Desktop app, Terminal or source? Source build. Strata 0.1.45, `serve/server.py`, Linux. The image job runs `engine-image/sd-cli` (stable-diffusion.cpp) with Qwen-Image-2.1-Turbo. ### What happened `POST /v1/images/generations` with `size=1536x1024` fails; `1024x1024` works. The service reports: ``` [strata] image: 1536x1024, n=1, 8 steps, seed 205380810 [strata] image job failed: sd-cli exited with code -6 #10 ... in GGMLRunner::execute_graph(...) #12 ... in WAN::WanVAERunner::_compute(int, sd::Tensor<float> const&, bool) () #13 ... in VAE::compute_with_temporal_tiling(...) #14 ... in VAE::decode(...) #16 ... in StableDiffusionGGML::decode_first_stage(...) ``` Running `sd-cli` directly with the same arguments shows the real error above the backtrace: ``` [E] ggml: ROCm error: out of memory [E] ggml: current device: 0, in function alloc at ggml/src/ggml-cuda/ggml-cuda.cu:510 [3] ggml_cuda_error(...) [4] ggml_cuda_pool_leg::alloc(unsigned long, unsigned long*) () [5] ggml_cuda_mul_mat_cublas(...) [12] WAN::WanVAERunner::_compute(...) [13] VAE::compute_with_temporal_tiling(...) [16] StableDiffusionGGML::decode_first_stage(...) ``` So the crash is **not** in the sampling step: sampling completes, and the abort happens in the **VAE decode**, when the latent is expanded into pixels and a large contiguous allocation fails. The failure is **not** caused by the text model holding VRAM: it reproduces with the engine unloaded and both cards completely free (VRAM 0%). ### Why 1024x1024 works and 1536x1024 does not The VAE decode peak allocation grows with the pixel count. On one 24 GB card, with the three model files (7.6 GB Q8_0 denoiser + 5.1 GB Qwen3-VL-8B conditioner + 0.7 GB VAE) resident in VRAM, the decode has roughly 10 GB left, which is enough for 1024x1024 but not for 1536x1024. Measured with the same model on one card (engine unloaded, both cards idle): | size | without `--vae-tiling` | with `--vae-tiling` | |---|---|---| | 1024x1024 | OK | OK | | 1536x1024 | **out of memory** | OK (35.9 s) | | 1536x1536 | out of memory | OK (57.7 s) | | 2048x1024 | out of memory | OK (50.1 s) | | 2048x2048 | out of memory | OK (135.3 s) | `--vae-tiling` (256x256 tiles) fixes every size; the images have no visible seams. ### Suggested fix Add `--vae-tiling` to the sd-cli arguments that `tools/image/install.py` writes, the same way the Vulkan setup already does it. `docs/IMAGES.md` says: > On Vulkan setup adds `--vae-tiling --vae-tile-overlap 0.25`: an untiled 1024x1024 VAE decode on a Radeon 780M is one GPU job long enough to trip the kernel driver's job timeout (no image) The HIP backend gets no such automatic flag, so on a 24 GB RDNA3 card the Qwen-Image-2.1-Turbo VAE decode runs out of memory from 1536x1024 upwards. It looks like the tiling (and the tile overlap) should be added for the HIP backend as well, or at least that the setup should warn when the planned resolution does not fit. Note that `need_mib` in `serve/images.py` (models + 2 GiB + 4 GiB per megapixel) underestimates the VAE decode peak, so 1536x1024 passes the planning check and then fails in the job. The formula or the check may want the decode peak too. ### Smallest steps or command that reproduce it ```bash M=/path/to/qwen-image-2.1-turbo ./engine-image/sd-cli \ --diffusion-model $M/qwen-image-2.1-turbo-Q8_0.gguf \ --vae $M/qwen_image_2.1_vae_bf16.safetensors \ --llm $M/Qwen3-VL-8B-Instruct-UD-Q4_K_XL.gguf \ -p "a serene mountain lake at sunset" --steps 8 --cfg-scale 1.0 \ --sampling-method euler \ --sigmas "1.0,0.978453,0.95418,0.926626,0.89508,0.845148,0.704534,0.414568,0.0" \ -W 1536 -H 1024 -s 42 -o /tmp/out_%03d.png --diffusion-fa ``` Exit code 134 (SIGABRT) with the out-of-memory error above. Adding `--vae-tiling` makes it succeed. ### Environment - GPU: 2x AMD Radeon RX 7900 XTX 24 GB (gfx1100, Navi 31), ROCm 7.2.4, `backend: hip` - Kernel 6.8.0, Ubuntu 22.04 - Model: Qwen-Image-2.1-Turbo Q8_0, 8 steps, CFG 1, euler, Turbo's own sigmas - stable-diffusion.cpp `2988060a4338a5dcd94721c964a8e87003c1ac8b`, ggml `d25b121ce1d6ae0c7e62ad080460d9fc1e46dd93` - Strata 0.1.45, source build, HIP
bsakaguchi 2026-11-04 01:52:31 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 23, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".
  • Fill in "Reproduction status".
  • Fill in "Strata version".
  • Fill in "Graphics card, memory and system".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6356501821 --> @github-actions[bot] commented on GitHub (Oct 23, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". - [ ] Fill in "Reproduction status". - [ ] Fill in "Strata version". - [ ] Fill in "Graphics card, memory and system". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 28, 2026):

Closing this issue because it still did not follow the format after 5 days. That is housekeeping, not a rejection.

To bring it back: fix the title (area prefix) and the missing parts, then comment /reopen. A check runs and reopens it, or tells you what is still missing. See CONTRIBUTING.md.

<!-- gh-comment-id:6466827728 --> @github-actions[bot] commented on GitHub (Oct 28, 2026): Closing this issue because it still did not follow the format after 5 days. That is housekeeping, not a rejection. To bring it back: fix the title (area prefix) and the missing parts, then comment `/reopen`. A check runs and reopens it, or tells you what is still missing. See [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1598
No description provided.