Repository navigation
spark-runtime: don't report host MemAvailable as device free on a carve-out APU - #182
Merged
Merged
Conversation
…ve-out APU cuda_free_memory_bytes and the backend's free_memory took max(cuMemGetInfo free, /proc/meminfo MemAvailable), which is right where the device draws from host RAM (GB10, GTT-backed Strix Halo). On an APU with a dedicated carve-out larger than host RAM it is wrong: the 128 GB Framework at a 96 GiB BIOS carve-out has 31 GiB of host RAM, so every free-memory read during a Flash-Next load returned the ~26-27 GB of host MemAvailable while the carve-out filled (sysfs vram_used peaked at 92.5 GiB). The KV budget and the MoE transpose tier were sized from it and the first KV alloc hit a full device (#145). unified_free() applies the MemAvailable floor only when the device total is no more than ~10% above host MemTotal. Unit tests cover GB10, GTT Strix and the carve-out case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(500-LoC cap) The carve-out fix took cuda_backend.rs from 475 to 545 lines. unified_free, the /proc/meminfo readers and their tests move to a sibling module; the call sites are unchanged (re-exported into cuda_backend). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 18, 2026
Merged
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.
cuda_free_memory_bytesand the backend'sfree_memoryreturnmax(cuMemGetInfo free, /proc/meminfo MemAvailable). That's correct where the device draws from host RAM (GB10, a GTT-backed Strix Halo), and wrong on an APU with a dedicated carve-out larger than host RAM.Measured on the 128 GB Framework (96 GiB BIOS carve-out, 31 GiB host RAM, Linux, ROCm 7.13):
mem_info_vram_usedclimbed to 92.5 GiB; process GTT was 8 MiB.Fix:
unified_free()applies the MemAvailable floor only when the device total is at most ~10% above host MemTotal. It's unit-tested: GB10 and GTT Strix keep the floor; the carve-out case does not.Effect
🤖 Generated with Claude Code