Commit 54a9141
fix(vram): reclaim idle pool after session teardown + offload upload encoder
Session start/close cycles left the pod sitting on the session's
transient allocation peak: measured driver-level, ~3.6-4.7 GB idle
after a plain 60s session and ~6 GB after one that swapped to the
240s decoder profile, on a server whose true idle floor is ~1 GB.
No objects leak — teardown frees its last tensors asynchronously
(recv thread joined with timeout, polygraphy/TRT finalizer chains),
AFTER every in-band empty_cache() has already run, so the freed
blocks stay reserved in PyTorch's caching pool indefinitely. That
pool is invisible to TensorRT's cudaMalloc workspaces, so it eats
exactly the headroom the next session's engine loads and swap-time
stem extraction need — the slow 'OOM over time' pattern on fleet
pods.
- ws_adapter: idle VRAM janitor — when no session is registered and
the pool holds >512 MiB of freed blocks, gc.collect() +
empty_cache(). Idle-only by construction; never competes with the
realtime loop. Cycle-tested: idle returns to ~1 GB after every
session (was 3.6-6 GB).
- ws_adapter: final trim in handle_client after the body frame (the
last session-ref holder) is gone.
- ws_adapter: the upload-encoder Session now offloads to CPU
(offload_to_cpu + offload_dit_to_cpu). It previously pinned a full
eager DiT+VAE+text-encoder copy (~6 GB) on the GPU permanently
from the first upload onward, next to the streaming TRT engines.
prepare_source hops weights per call; uploads measured 14-22s and
settle at ~1.4 GB.
- Session: expose offload_dit_to_cpu (passthrough to ModelContext);
without it offload_to_cpu lets the DiT go GPU-resident on first
use.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 1200019 commit 54a9141
3 files changed
Lines changed: 125 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
| |||
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
594 | 600 | | |
595 | 601 | | |
596 | 602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 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 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
101 | 172 | | |
102 | 173 | | |
103 | 174 | | |
| |||
122 | 193 | | |
123 | 194 | | |
124 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
125 | 205 | | |
126 | 206 | | |
127 | 207 | | |
128 | 208 | | |
129 | 209 | | |
| 210 | + | |
| 211 | + | |
130 | 212 | | |
131 | 213 | | |
132 | 214 | | |
| |||
278 | 360 | | |
279 | 361 | | |
280 | 362 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
289 | 390 | | |
290 | 391 | | |
291 | 392 | | |
| |||
0 commit comments