mirror of
https://github.com/Comfy-Org/comfy-aimdo.git
synced 2026-11-04 23:37:21 +00:00
[GH-ISSUE #83] [ROCm/Windows] vbar_allocate clamps every VBAR reservation to vram_capacity, exhausting the GPU address space after three models #26
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-aimdo#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doesdev on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-aimdo/issues/83
Summary
vbar_allocateclamps each VBAR's VA reservation tovram_capacity, so on a large-VRAM device every model reserves the full device capacity worth of address space regardless of its actual size. Three models exhaust the ~256 GiB per-process GPU VA space available on ROCm/Windows, after which allocations fail withhipErrorOutOfMemorywhile tens of GB are still free.Changing one multiplier in ComfyUI takes peak usage on a 43 GiB LTX workflow from 26,978 MB to 81,522 MB and turns a hard failure into a clean run.
Environment
--enable-dynamic-vram --disable-async-offload --enable-managerMechanism
src/model-vbar.c:222-227:ComfyUI calls
ModelVBAR(self.model_size() * 10, ...)fromcomfy/model_patcher.py_vbar_get. Withvram_capacity= 110,456 MB the clamp is 3451 pages = 110,432 MB, so any model above roughly a tenth of device capacity reserves 110,432 MB of VA irrespective of size:model_size() * 10On ROCm/Windows the per-process GPU VA space is ~256 GiB and physical VMM allocations draw from the same budget. That is measured separately with a standalone reproducer and reported as ROCm/rocm-systems#9823. 256 GiB minus 229.2 GiB leaves about 27 GiB for anything to actually be mapped into.
Observed
Two runs, aimdo DEBUG level, differing only in
--disable-pinned-memory:Aimdo Recorded Usageat failureDevice freeat failureTotal VRAM for VBARsFree memory differs by 21,696 MB; the failure point differs by 192 MB, which is six 32 MB pages. The ceiling does not track free memory.
budget_deficit()never returns positive in either run (noDeficit:line anywhere in the DEBUG logs), so aimdo is not throttling. Thebudget_deficit(VBAR_PAGE_SIZE) > 0short-circuit atsrc/model-vbar.c:390does not fire,three_stooges()is actually called, and it returnsCUDA_ERROR_OUT_OF_MEMORYfor a 32 MB allocation with 60-82 GB free.Symptoms this produces, in order of appearance in one session:
CUDA error: out of memoryat the first sampler step, at a consistent ~27 GB regardless of resolution or workload size.ERROR lora <weight> CUDA error: out of memorylines, after which the run completes and reports success having silently dropped those patches. This is the worst of the three, because the output looks plausible.OSError: exception: access violation reading 0x00000000000000E0frommodel_vbar.py:52, when a later node (LTXVLatentUpsampler) requests a fourth reservation andhipMemAddressReservefaults instead of returning an error. Same crash as #63 and #45.Fix that works
comfy/model_patcher.py,_vbar_get:self.model_size() * 10toself.model_size() * 2.* 10* 2Aimdo Recorded UsageTotal VRAM for VBARsvbars_analyzewarnings81,522 MB compares with 87.2 GB peak for the identical workflow on Fedora 44 on this same machine.
* 2is not proposed as the fix, only as evidence. The upstream comment on that line says the 10x exists to cover a full FP4 to FP32 upcast, which* 2does not. Two directions that would preserve the intent:vbar_allocatereport the clamped size back to Python instead of clamping silently, so the caller can react.Note on the clamp and
max_sizevbar_allocateclamps the reservation butcomfy_aimdo/model_vbar.py:56stores the caller's unclampedsizeasself.max_size, andalloc()bounds-checks against that. When the clamp engages, Python believes it owns more address space than was reserved. It does not trigger here because offsets stay well under the clamped size, and it disappears at* 2since nothing clamps. Mentioning it only because it is adjacent to the same code; happy to open it separately if preferred.Related
VramBufferon ROCm/Windows to avoid the same fault.model-vbar.chas no equivalent, so each model load still reserves and frees its own window. Reducing the per-VBAR size addresses more of the problem than pooling does, but the two compose.@coderabbitai[bot] commented on GitHub (Aug 7, 2026):
🔗 Related PRs
Comfy-Org/comfy-aimdo#62 - Dev/double sync [closed]
Comfy-Org/comfy-aimdo#72 - Added support for MCDM and GPU-PV through the DXCore API [open]
Comfy-Org/comfy-aimdo#78 - Implement NVML pressure and async pre-free clamping [merged]
Comfy-Org/comfy-aimdo#80 - Refs/heads/dev/threaded loaded errors [merged]
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!