Repository navigation
Description
I found a reproducible GPU offload issue with Unsloth Studio on a Ryzen AI Max+ 395 / Radeon 8060S (gfx1151) using ROCm 7.13.
Environment
- CPU/APU: AMD Ryzen AI Max+ 395
- GPU: Radeon 8060S Graphics (gfx1151)
- ROCm/HIP: 7.13.99004
- Unsloth Studio: current version as of 2026-08-13
- llama.cpp build: 10360 (
90e6a9131) - OS: Windows 11 + WSL2
- PyTorch: ROCm build,
torch.cuda.is_available() == True
PyTorch correctly reports the unified memory pool:
torch.cuda.is_available() = True
device_count = 1
GPU 0:
free = 46.37 GiB
total = 47.48 GiB
name = AMD Radeon(TM) 8060S Graphics
Baseline: llama.cpp directly
Running the bundled llama-server directly with:
--gpu-layers 33 --fit off
works correctly:
ROCm0 : AMD Radeon(TM) 8060S Graphics (48615 MiB, 31704 MiB free)
...
offloaded 33/33 layers to GPU
CPU_Mapped model buffer size = 545.62 MiB
ROCm0 model buffer size = 5147.13 MiB
So ROCm, HIP, llama.cpp, and GPU offload itself are working correctly.
Unsloth Studio
Unsloth Studio also generated the correct command line:
--gpu-layers 33 --fit off
However, Studio additionally injected this environment variable:
GGML_CUDA_ENABLE_UNIFIED_MEMORY=1
The relevant code in studio/backend/core/inference/llama_cpp.py was:
if not is_vulkan_backend and self._amd_apu_wants_unified_memory(gpu_indices):
env.setdefault("GGML_CUDA_ENABLE_UNIFIED_MEMORY", "1")
logger.info("AMD unified-memory APU: set GGML_CUDA_ENABLE_UNIFIED_MEMORY=1")With this variable present, the model was not being placed in the GPU memory as expected.
Workaround / confirmation
I disabled only the automatic setting of:
GGML_CUDA_ENABLE_UNIFIED_MEMORY=1
while keeping the same:
--gpu-layers 33 --fit off
After removing that environment variable, GPU offload started working correctly in Unsloth Studio.
This strongly suggests that forcing GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 for Strix Halo / gfx1151 is incorrect or conflicts with the normal ROCm unified-memory behavior of llama.cpp.
Additional observation
I also found the separate APU RAM checks discussed in issue #6834, where Studio uses psutil.virtual_memory().available for unified-memory APUs. I temporarily disabled those checks while investigating, but the decisive change for GPU offload was disabling the automatic:
GGML_CUDA_ENABLE_UNIFIED_MEMORY=1
The same llama.cpp binary works correctly without that variable.
Could this environment-variable handling be changed for gfx1150/gfx1151 so that GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 is not forced?
I believe this is particularly relevant for Strix Halo systems where ROCm already exposes the shared memory pool correctly through torch.cuda.mem_get_info() and llama.cpp can successfully offload all layers without this variable.
Activity
danielhanchen commentedon Aug 13, 2026
Thanks, this is a good report and the mechanism checks out. I can confirm the behaviour you describe and add two things you could not see from outside.
What the variable actually does. In
ggml/src/ggml-cuda/ggml-cuda.cuthere is exactly one use site, inggml_cuda_device_malloc:Under HIP the managed branch additionally applies
hipMemAdviseSetCoarseGrainas a hint, and falls back to plainhipMallocif the runtime answershipErrorNotSupported. So with the variable present, model buffers come fromhipMallocManagedand are migratable pages rather than an ordinary device allocation, which is exactly the difference between your twoROCm0 model buffer sizeoutcomes.The part that makes it worse than a bad default: only the variable's PRESENCE is checked, not its value.
getenv(...) != nullptrmeansGGML_CUDA_ENABLE_UNIFIED_MEMORY=0still enables managed memory. Studio sets it withenv.setdefault(..., "1")and the comment says "so a user value wins", which is true in the sense that Studio will not overwrite yours, but there is no value you can set that turns it off. That is why patching the source was your only route, and it is a defect independent of whether the default is right.Where it came from. The variable was introduced by #5301, "fix/strix halo and windows AMD ROCm support", so it was added for your exact hardware. That is worth stating plainly rather than treating your report as contradicting it: both can be true if the right behaviour depends on the memory split.
Which is what I would like to pin down before changing the default. Your pool is large:
On a Strix Halo configured that way, plain
hipMallochas plenty to work with and managed memory only adds migration. On a host with a small BIOS VRAM carve-out that leans on GTT, the managed path may be the only way a model fits at all, which is the case #5301 was solving. If so the fix is not "never set it for gfx115x" but "set it only when the allocation could not be satisfied otherwise", plus a real off switch.Could you post your carve-out, so I size the fix to both configurations rather than trading your bug for someone else's:
rocminfo | grep -A2 "Pool Info"for the GPU agent, oramd-smi static --vramRegardless of that answer, two things are going in: an escape hatch that genuinely disables it (which cannot be the variable itself, given the presence check), and a correction to that misleading "a user value wins" comment.
Related, not duplicates, all still open: #6834 (Strix Halo loading restricted to system RAM, which you also hit), #7371 (Strix Halo performance regression) and #7380 (Strix Halo startup crash). #6757 is the same variable on unified-memory NVIDIA (DGX Spark / GB10), so any change here should be checked against that path too, since the same code sets it for a very different reason there.
danielhanchen commentedon Aug 13, 2026
Opened #8680 with the escape hatch half of this, since it is needed whichever way the default goes.
UNSLOTH_DISABLE_UNIFIED_MEMORY=1now keeps the variable unset, and a falsyGGML_CUDA_ENABLE_UNIFIED_MEMORY(0,false,no,off, empty) is stripped rather than passed through, since ggml would otherwise read your "0" as on. That should give you the same result as your source patch without one. The default for gfx1150/gfx1151 is unchanged in that PR.Still interested in the carve-out numbers when you get a chance, so the default itself can be sized to both your large-pool configuration and the small-carve-out host #5301 was originally solving.
Tighten the #8651 unified-memory comments
makaroni03 commentedon Aug 13, 2026
Thanks for the clarification and for adding the escape hatch.
For my system, the configuration is:
GMKtec EVO-X2
Ryzen AI Max+ 395 / Radeon 8060S (gfx1151)
64 GB unified memory
Windows 11 + WSL2
ROCm 7.13
BIOS: EVO-X2 1.12 (2025-12-09)
BIOS VRAM allocation is configurable from 0.5 GB to 48 GB.
I tested 0.5 GB, 4 GB and 32 GB allocations. Windows still reports 48 GB of shared GPU memory in all cases.
rocminfo reports a ~47.6 GiB coarse-grained GPU memory pool:
49967194 KB
With GGML_CUDA_ENABLE_UNIFIED_MEMORY=1, the model uses managed/shared memory backed by system RAM instead of this coarse-grained pool.
Thanks again for investigating this.
Studio: give GGML_CUDA_ENABLE_UNIFIED_MEMORY a real off switch (#8651) (
Studio: gate GGML_CUDA_P2P on a confirmed NVLink fabric, not a produc…