Fix AMD APU VIS_VRAM detection: swapped constants, None crash, and code duplication#3
Draft
Fix AMD APU VIS_VRAM detection: swapped constants, None crash, and code duplication#3
Conversation
Co-authored-by: Readon <3614708+Readon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [gpustack/runtime#9] Fix issues found by gemini-code-assist and copilot
Fix AMD APU VIS_VRAM detection: swapped constants, None crash, and code duplication
Mar 15, 2026
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.
Four bugs identified in PR review (Gemini + Copilot) of the AMD APU unified-memory VRAM detection feature.
Fixes
Swapped memory type constants (
pyrocmsmi/__init__.py):RSMI_MEM_TYPE_VIS_VRAMwas2andRSMI_MEM_TYPE_GTTwas1— inverted vs. the ROCm SMI spec (rsmi_memory_type_tenum: VIS_VRAM=1, GTT=2). The APU fix was silently querying GTT instead of VIS_VRAM.NameErrorin memory function defaults (pyrocmsmi/__init__.py):rsmi_dev_memory_total_get/rsmi_dev_memory_usage_getdefaulted torsmi_memory_type_t.RSMI_MEM_TYPE_VRAM, which is only in scope whenrsmiBindingsimports successfully (guarded by a conditional block). Replaced with the always-available numeric constantRSMI_MEM_TYPE_VRAM = 0.TypeErroronNoneVRAM values (amd.py):amdsmi_get_gpu_vram_usage().get("vram_total")can returnNone, causingmax(None, dev_mem_vis_vram)to raiseTypeError. Normalized withor 0.Duplicated VIS_VRAM correction logic (
amd.py): The VIS_VRAM override block was copy-pasted into both thepyamdsmitrybranch and thepyrocmsmifallbackexceptbranch. Moved it to after the try/except so it applies once regardless of which path resolveddev_mem.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.