Avoid repeated model eviction during single-frame Wan 2.1 VAE image decoding
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- machine-learning, performance
Research direction
The issue identifies #18084 as the proposed implementation and mentions existing single-frame optimizations in #12090 and #12036; it does not name source files or tests. Start by reviewing those issues and tracing the decode admission estimate and OOM retry path. Done means resident models are preserved when eligible decoding fits, while retry and tiled fallback behavior and output semantics remain intact; CUDA validation across geometries and hardware is still required.
Written by the indexing model from the issue text.
Description
Problem
A fully resident stock Wan 2.1 VAE can unnecessarily evict unrelated diffusion-model and text-encoder weights before an untiled single-frame decode. The conservative decode admission estimate does not distinguish this path from short-video decoding, despite existing single-frame optimizations (#12090, #12036).
This creates a repeated offload/reload cycle during otherwise warm image generation, including HIGH_VRAM mode.
Reproduction and measured impact
Observed on NVIDIA RTX PRO 6000 Blackwell (96 GB), PyTorch 2.10.0+cu130, CUDA async allocator, HIGH_VRAM, dynamic VRAM disabled, BF16 Wan 2.1 VAE, batch-one 16-channel single-frame latent at 572 × 572 (4576 × 4576 output).
Three baseline and four patched lifecycle traces were inspected for #18084. All four patched final decodes completed without observed OOM, conservative retry or tiled fallback.
| Metric | Baseline | Patched |
|---|---|---|
| Decode memory reservation | 85.81 GiB | 58.50 GiB |
| Diffusion/text-encoder weights evicted during decode | 17.29 GiB/run | 0 |
| Final VAE model admission time | 2.623–2.841 s | 0.002–0.003 s |
| Initial text-encoder load, warm runs | 3.846–10.866 s | 0.001–0.002 s |
| Initial diffusion-model load, warm runs | 3.347–3.478 s | 0.001–0.002 s |
| Final VAE decode including admission, warm runs | 5.917–6.149 s | 2.777–3.521 s |
The two comparable patched warm runs averaged 70.89 s versus 96.80 s for three baseline runs. This is observational across a process restart, not an isolated throughput benchmark. Weight residency and admission timings directly establish the intended effect; the entire wall-time difference cannot be attributed to the change.
Proposed fix
- #18084 — preserve the existing estimator for video, batches and other configurations. For the narrowly eligible resident single-frame CUDA path, attempt a smaller admission reservation only if it fits with the existing reserve and the original budget does not.
- Retain the original conservative reservation as the OOM retry path before the existing tiled fallback.
- Preserve decoder arithmetic, model ownership, error propagation and bounded failed-attempt state.
The reduced admission estimate is an optimistic trial, not a universal bound on peak memory. Exact same-input GPU parity and real constrained-memory retry behavior remain to be verified; 31 targeted isolated CPU regression cases passed with backend/model-management dependencies mocked.
Scope
This is independent of decoder strip processing (#17270) and the request-path performance work in #18142 / Comfy-Org/ComfyUI_frontend#24775. It addresses avoidable model residency churn, not a frontend freeze or sampler optimization.
Related reports: #14618 and #17469 describe model reload/residency symptoms, but their exact causes have not been established as identical.
Acceptance
- Preserve resident models when the eligible untiled single-frame decode fits.
- Retain safe retry and existing fallback behavior under memory pressure.
- Preserve noneligible decode paths and output semantics.
- Complete upstream review and CUDA validation across relevant geometries and hardware.
- Dominant language
- Python
- Stars
- 150k
- Forks
- 17.9k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 181
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Comfy-Org/ComfyUI
-
UnboundLocalError on a dangling symlink in custom_nodesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Feature
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
ModelMergeSimple and all merge nodes are O(N²)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Comfy-Org/ComfyUI#17823 · 1 reaction ·
Maintainers usually reply within 1 day
-
[Ascend NPU] Trellis2 shape stage aborts: aten::max.dim has no INT32 kernel (EZ1001)Possibly taken @harmehak0173 claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
All issues in Comfy-Org/ComfyUI
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day