Repository navigation
fix: reclaim before accepting wrapped Vulkan iGPU memory estimates - #2124
Conversation
leejet
left a comment
There was a problem hiding this comment.
free_bytes > total_bytes can also occur under genuine memory pressure when heap usage exceeds its budget. Replacing it with total_bytes can make fits() return true and bypass workspace/weight eviction in ensure_compute_backend_capacity(). If the subsequent allocation fails, the segment aborts without retrying after reclamation. This can regress workloads that previously succeeded after evicting cached allocations.
Could we retain the fallback but reclaim eligible allocations and retry on allocation failure, or attempt reclamation before accepting this optimistic estimate?
|
Changed it to reclaim eligible workspaces and cached weights before accepting the estimate, including through the public capacity precheck. The Vulkan build and all 25 local checks pass. SD 1.5 completes on the Radeon 610M with both normal and injected |
Summary
For Vulkan integrated GPUs reporting
free > total, retain the tracked-residency fallback but require reclamation before accepting it: invalid report → attempt workspace and eligible weight reclamation → accept the estimate only if the capacity limits pass.Both the public capacity precheck and intermediate checks in
ensure_compute_backend_capacity()reject early success based on this estimate. The public check also prevents callers from skipping reclamation and conservatively selects segmentation when a usable cut plan exists. Reclamation attempts are skipped when the eviction candidate set has not grown, avoiding repeated driver queries for ineligible candidates.Addresses the invalid-report path discussed in #2022. Discrete Vulkan GPUs retain the existing rejection of
free > total.Evidence
SD_VULKAN=ONcompleted; formatting checks on modified lines andgit diff --checkpassed.free = total + 1024runs both exited successfully, completed sampling and VAE decoding, and saved byte-identical PNGs. The injected run recorded 45 device-weight release events. The temporary injection hook was removed and production artifacts rebuilt.Merge Danger
The change is reversible and limited to ModelManager capacity and reclamation decisions. Existing protection filters and device/budget limits remain in place; ordinary sufficient-memory reports retain their fast path.
The fallback remains a best-effort estimate after eligible reclamation has been attempted. Artificial injection validates this execution path but does not reproduce the original Intel driver behavior or demonstrate recovery from genuine memory exhaustion. Honest low-free reports, including the Linux GTT case discussed in #2022, are outside this change.
Summary by CodeRabbit