Win: Use DXGI for accurate WDDM VRAM memory budget - #4457
Open
dhiltgen wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
This slightly contrived example runs mlx-lm and evicts old caches under memory pressure. |
zcbenz
force-pushed
the
win-wddm-memory-budget
branch
from
September 7, 2026 23:48
006767f to
c2fccfd
Compare
zcbenz
reviewed
Sep 8, 2026
Comment on lines
+133
to
+138
| size_t windows_memory_limit( | ||
| size_t memory_limit, | ||
| const std::vector<cudaMemPool_t>& pools) { | ||
| static WddmMemoryBudget budget(pools.size()); | ||
| return budget.get_memory_limit(memory_limit, pools); | ||
| } |
Member
There was a problem hiding this comment.
The allocator of MLX is currently not aware of multi-device and just assumes all devices share same memory size and limits. So this function should return per-device limit instead of accumulation.
Suggested change
| size_t windows_memory_limit( | |
| size_t memory_limit, | |
| const std::vector<cudaMemPool_t>& pools) { | |
| static WddmMemoryBudget budget(pools.size()); | |
| return budget.get_memory_limit(memory_limit, pools); | |
| } | |
| size_t get_windows_memory_limit( | |
| size_t hard_memory_limit, | |
| int device, | |
| cudaMemPool_t pool) { | |
| static WddmMemoryBudget budget(device_count()); | |
| return budget.get_memory_limit(hard_memory_limit, device, pool); | |
| } |
dhiltgen
force-pushed
the
win-wddm-memory-budget
branch
from
September 8, 2026 21:38
c2fccfd to
3f5473a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WDDM implements VRAM paging, which can result in a performance cliff at the limit. This wires up DXGI to expose more accurate VRAM budget.