Commit f4100ca
committed
Version 1.1.14
Included in Version 1.1.14
Summary
We implemented a complete memory-management upgrade for ETUR refiners (PRO + CE) to support low-spec systems and very large tile counts.
This combined plan delivers:
1. meaningful 3-profile memory modes,
2. clear PRO tooltip text explaining tradeoffs,
3. CE forced to lowest-memory behavior,
4. RAM-based automatic fallback (cross-platform),
5. strict `Ultra Low` mode that unloads/reloads models between stages/tiles for minimum VRAM usage.
Target scenario: 100 tiles, 2048x2048 input, denoise mask + image stabilizer + Redux + 3 ControlNets.
---
PRO node input change
We replaced the boolean `Low_Vram` with enum `VRAM_Profile`.
Final profile names
1. `Fast Cache (Max Speed)`
2. `Low VRAM Cache (Unload Models)`
3. `Ultra Low Memory (Per-Tile Streaming)`
### PRO tooltip (final text)
- `Fast Cache (Max Speed)`: Precomputes full tile conditioning (text + Redux + ControlNet) for all tiles and keeps models loaded. Fastest sampling, highest RAM/VRAM usage.
- `Low VRAM Cache (Unload Models)`: Precomputes full tile conditioning, then unloads models to reduce VRAM. RAM can still be high with many tiles.
- `Ultra Low Memory (Per-Tile Streaming)`: Caches repeated text conditioning only; Redux/ControlNet are rebuilt per tile and released immediately. Also unloads/reloads models between steps/tiles for minimum VRAM. Slowest mode; best for very low-spec systems.
CE node behavior
- No new CE UI input.
- Force CE internally to `Ultra Low Memory (Per-Tile Streaming)`.
Backward compatibility
Map legacy workflows with `Low_Vram`:
- `True` -> `Low VRAM Cache (Unload Models)`
- `False` -> `Fast Cache (Max Speed)`
- If CE path has no field -> force Ultra Low.
---
## 2) Runtime Profile Semantics
### A. Fast Cache (Max Speed)
- Full precompute for all selected tiles:
- text conditioning
- Redux conditioning
- ControlNet conditioning
- Keep models resident.
- Highest memory usage, best speed.
### B. Low VRAM Cache (Unload Models)
- Same full precompute as Fast Cache.
- Then unload models / soft-empty cache before tile sampling loop.
- Lower VRAM than Fast Cache, RAM still high due to full caches.
### C. Ultra Low Memory (Per-Tile Streaming)
- Precompute text-only deduplicated cache.
- For each tile:
- build dynamic conditioning on demand (Redux + ControlNet)
- consume immediately
- drop refs + unload models + flush cache
- Between stages and between tiles:
- aggressive unload/reload cycle.
- Slowest, lowest VRAM and significantly lower RAM.
---
## 3) RAM-Based Auto Fallback (PRO)
Scope
- RAM-based only (not VRAM-based), per your requirement.
- Applied to PRO before heavy precompute starts.
### Cross-platform RAM probing
Primary:
- `psutil.virtual_memory().available` and `.total`
Fallbacks if `psutil` unavailable:
- Windows: `ctypes` `GlobalMemoryStatusEx`
- Linux: parse `/proc/meminfo` (`MemAvailable`)
- macOS: `vm_stat`/page-size parsing (+ `sysctl hw.memsize` for total)
If all probes fail:
- Log warning; run selected profile without auto-fallback.
Decision rule
- Estimate required RAM for selected profile.
- Safety threshold:
- require `available_ram >= estimate * 1.25 + 1.5GB`
- If unsafe:
- auto-switch to `Ultra Low Memory (Per-Tile Streaming)`
- log decision and numbers.
- If selected profile already Ultra Low:
- no upward fallback.
---
## 4) Estimation Model
### Fast / Low VRAM Cache estimate
- Baseline process overhead
- + per-tile unified conditioning cache estimate (all tiles):
- sample tensor dimensions from representative tile
- dtype factor
- conditioning structure overhead multiplier
Ultra Low estimate
- Baseline
- + text-only cache estimate
- + one-tile transient working set (not multiplied by tile count)
## 5) Code Changes
Files
- [`py/nodes/UpscalerRefiner/TBG_Nodes_PRO.py`](a:/SD/ComfyUI_070_cu128/ComfyUI/custom_nodes/ComfyUI-TBG-ETUR/py/nodes/UpscalerRefiner/TBG_Nodes_PRO.py)
- [`py/nodes/UpscalerRefiner/TBG_Nodes_CE.py`](a:/SD/ComfyUI_070_cu128/ComfyUI/custom_nodes/ComfyUI-TBG-ETUR/py/nodes/UpscalerRefiner/TBG_Nodes_CE.py)
- [`py/nodes/UpscalerRefiner/TBG_Refiner.py`](a:/SD/ComfyUI_070_cu128/ComfyUI/custom_nodes/ComfyUI-TBG-ETUR/py/nodes/UpscalerRefiner/TBG_Refiner.py)
- [`py/nodes/UpscalerRefiner/inc/vram_optimizing.py`](a:/SD/ComfyUI_070_cu128/ComfyUI/custom_nodes/ComfyUI-TBG-ETUR/py/nodes/UpscalerRefiner/inc/vram_optimizing.py)
- New helper: `inc/memory_probe.py` (or equivalent)
Patched the skippend Cnet Log bug in ETUR.
What I changed
I updated vram_optimizing.py:
Removed the invalid SELF.INPUTS.controlnetimage gate (that field is never set in this path). Just triggering a wrong log output confusing users
ControlNet preprocessors now validate real sources:
use custom_controlnet_image (noise_image) if provided
otherwise use per-tile image
Fixed a second bug: it now applies filtered_pipe (not the original pipe).
Why your log looked contradictory
You saw both:
Skipping ... no controlnetimage
and Depth model loading each tile
That happened because the code was logging skip during filtering, but still executed the original unfiltered cnet pipe afterward. The patch fixes that mismatch.
Changes made
Updated cnet.py:
Logs at tile start: how many ControlNet pipe entries will be processed.
Logs per entry before apply:
model
preprocessor
source (tile_image vs custom_controlnet_image)
effective strength, start, end
image_shape
Logs per entry after apply: conditioning applied.
Updated vram_optimizing.py:
Logs selected filtered entries per tile before precompute.
Keeps the earlier fix:
no bogus controlnetimage gate
uses filtered_pipe for execution.1 parent 9f5aa5f commit f4100ca
8 files changed
Lines changed: 656 additions & 175 deletions
File tree
- py/nodes/UpscalerRefiner
- inc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
419 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
420 | 438 | | |
421 | 439 | | |
422 | 440 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
15 | 28 | | |
16 | 29 | | |
17 | 30 | | |
| |||
177 | 190 | | |
178 | 191 | | |
179 | 192 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
188 | 209 | | |
189 | 210 | | |
190 | 211 | | |
| |||
197 | 218 | | |
198 | 219 | | |
199 | 220 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
210 | 244 | | |
211 | 245 | | |
212 | 246 | | |
213 | 247 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
221 | 261 | | |
222 | 262 | | |
223 | 263 | | |
| |||
243 | 283 | | |
244 | 284 | | |
245 | 285 | | |
246 | | - | |
247 | | - | |
| 286 | + | |
| 287 | + | |
248 | 288 | | |
249 | 289 | | |
250 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
0 commit comments