mirror of
https://github.com/Comfy-Org/comfy-aimdo.git
synced 2026-11-04 23:37:21 +00:00
[PR #113] [MERGED] Fix malloc graph search skipping overlapping alias ranges #122
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#122
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?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-aimdo/pull/113
Author: @localbobthebuilder
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @rattus128
Base:
master← Head:fix/alias-range-search📝 Commits (3)
293de00Fix malloc graph search skipping overlapping alias ranges9ea5e09Assert physical page reuse in overlapping alias regressioncc93975Reuse cleanup scan to find the earlier conflicting alias📊 Changes
2 files changed (+42 additions, -3 deletions)
View changed files
📝
src/malloc-graph.c(+6 -3)➕
tests/malloc-graph-overlapping-alias-cuda.py(+36 -0)📄 Description
Fix allocation search skipping valid overlapping alias ranges
The malloc-graph allocator can extend its virtual range even when an existing
range satisfies the allocation. This wastes virtual address space and can
contribute to exhausting the fixed arena while physical graph memory remains
well below that limit.
During a candidate scan,
physical_liveincludes both pre-existing live pagesand pages temporarily marked live by that scan. When a repeated physical page
is encountered within the candidate, advancing by
j + 1skips overlappingwindows that no longer contain the earlier occurrence.
For example, with the free mapping
[0, 1, 2, 0, 1, 3]and a four-page request,the window starting at virtual index 2 is valid:
[2, 0, 1, 3]. The currentsearch misses it. Advance past the earlier occurrence on a temporary alias
collision; retain the existing advancement otherwise. This preserves the
requirement that a returned range contain distinct, available physical pages.
The standalone GPU regression creates that layout with small allocations:
stock grows virtual space from 48 to 80 MiB, while the correction reuses 48 MiB.
Physical space is 32 MiB in both cases. Distinct values per page check that
the returned range has no unintended physical aliasing. No model is required.
Validation on Windows / RTX 5090, Torch 2.14.0+cu130, AIMDO 0.5.3:
reference checked 2,866,560 mapping/live/rogue-mask cases. Stock missed 2,364
ranges; the candidate missed zero.
branch reuse, reordered free, variable subgraph replay, rogue alias, rogue
event splice and changed size.
(expected 56 MiB, observed 48 MiB). This is disclosed as a baseline mismatch;
assertions after that failure have not been counted as passing.
The exact submitted GPU regression was verified failing on stock and passing on
the patched native build. Existing GPU tests were run with
PYTORCH_ALLOC_CONF=backend:cudaMallocAsyncso their allocation hooks are active.Contribution agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.