Repository navigation
Studio: give GGML_CUDA_ENABLE_UNIFIED_MEMORY a real off switch (#8651) - #8680
Merged
Merged
Conversation
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Closes #8651.
What happens today
ggml/src/ggml-cuda/ggml-cuda.cuhas exactly one use site for the variable, inggml_cuda_device_malloc:Only the variable's PRESENCE is tested, never its value.
GGML_CUDA_ENABLE_UNIFIED_MEMORY=0therefore ENABLES managed memory. Studio set it withenv.setdefault(..., "1")and the comment said "setdefault so a user value wins", which was true only in the sense that Studio would not overwrite a value you set. There was no value anyone could set that turned it off, so the reporter's only route was patching Studio's source.That is a defect independent of whether the default is right for gfx1150/gfx1151, so it is what this PR fixes. The default is unchanged: #5301 added the variable for exactly this hardware, and I do not want to trade one host's bug for another's while the memory-split question is still open on the issue.
What happens after
Two ways to opt out, both of which end with the name absent from the child env, because absence is the only off state ggml understands.
UNSLOTH_DISABLE_UNIFIED_MEMORY=1, mirroring the existingUNSLOTH_DISABLE_DC_TUNING=1. Exact1, same as that switch.GGML_CUDA_ENABLE_UNIFIED_MEMORY(0,false,no,off, empty, trimmed and case-folded), which is what users reasonably expect to mean off. Studio now strips it rather than passing it through to be read as on.Any other value is passed through untouched, ownership tracking included.
Blast radius
The decision lives in a new
_unified_memory_opted_outhelper used only at the three env sites._amd_apu_wants_unified_memoryis deliberately left alone: two other consumers gate RAM admission on it (_offloads_every_layerand the APU RAM refusal at load time), and an env-var opt-out must not silently change what Studio believes about the hardware.The arch-crash retry re-adds the variable when it lands on an APU, so that branch is gated too, otherwise the opt-out would not survive a respawn. The two withdrawal branches already key off
_unified_env_applied, which is False under an opt-out, so they needed no change.Fails open: a hostile or unreadable env answers False, which is the pre-PR behaviour.
Tests
studio/backend/tests/test_amd_apu_unified_memory.py: 15 new cases over the helper, including a fail-open case.studio/backend/tests/test_gpu_arch_gate_os_matrix_7624.py: 16 new launch-level cases on the reported Strix Halo shape, covering the unchanged default, every off spelling, the truthy pass-through, the switch beating an inherited value, and the opt-out surviving an arch-crash retry onto an APU.Serial run,
-p no:randomly:test_gpu_arch_gate_consumers_7624.py,test_datacenter_gpu_tuning.py,test_llama_cpp_placement.py,test_gpu_init_crash_message.py,test_model_memory_settings.py: 886 passed, 0 failedEight mutations, no survivors, both directions on the guard:
popchanged tosetdefaultstrip().lower()droppedruff checkclean,scripts/run_ruff_format.pyapplied.Still open on the issue
I have asked the reporter for their BIOS carve-out,
rocminfopool info and whether they are on WSL2 or native, so the default itself can be sized to both a large-pool Strix Halo and the small-carve-out host #5301 was solving. That is a separate change; this one is the escape hatch, which is needed either way.