Skip to content

rocm: model weights in host RAM on integrated APUs (Strix Halo) - #1028

Open
Piega wants to merge 1 commit into
antirez:mainfrom
Piega:strixhalo-host-ram-weights
Open

rocm: model weights in host RAM on integrated APUs (Strix Halo)#1028
Piega wants to merge 1 commit into
antirez:mainfrom
Piega:strixhalo-host-ram-weights

Conversation

@Piega

@Piega Piega commented Sep 12, 2026

Copy link
Copy Markdown

Fixes OOM loading resident DeepSeek V4 Flash Q2 (80.76 GiB) on Strix Halo systems, and unlocks the other 128 GB UMA resident models on ROCm.

Problem

The ROCm model arena allocates weights with hipMalloc, which on integrated APUs is bound by the small device memory pool exposed to the GPU (~62 GiB, set by the BIOS UMA frame buffer). A resident Flash Q2 (80.76 GiB) therefore failed during tensor-span preparation:

ds4: model arena alloc failed for tensor-span:108 (528.00 MiB request): out of memory

Fix

On integrated APUs, allocate model arena chunks via hipHostMalloc (falling back to hipMallocManaged), mirroring how llama.cpp's GGML_HIP_UMA keeps weights in host RAM while they stay GPU-visible over the UMA fabric. Discrete GPUs keep the existing hipMalloc path untouched; DS4_ROCM_FORCE_DEVICE_MEM=1 restores the previous behavior.

Verified

Bosgame M5 (Ryzen AI Max+ 395, Radeon 8060S, 128 GB, ROCm 10.0, this branch).

DeepSeek V4 Flash models, resident:

model prefill (new interval) steady gen peak resident
Flash Q2 273-284 tok/s (ctx 4-8k) 13.0-13.7 tok/s 80.76 GiB
Flash Q2 + DSpark drafter 206-286 tok/s 22.8-24.3 tok/s 80.76 GiB + 5.6 GiB
Flash Q2-Q4 (L37-42 Q4K) 103-151 tok/s 13.1-13.6 tok/s 90.88 GiB

All load in ~30 s; KV is 0.41-0.46 GiB. GLM 5.3 Flash Q2 also runs resident (90 GiB) with DS4_GLM_MEMORY_GUARD=0 (the guard budgets from the ~61 GiB device pool); vision mode (V4 Flash Vision-Exp + encoder) works on ROCm.

Note: this approach is complementary to #361 (opt-in DS4_CUDA_MANAGED for high-context OOM on large-carveout UMA APUs): #361 addresses long-context scratch by defaulting weight/scratch placement policy on demand, while the change here makes resident weights work on integrated APUs out of the box by routing the weight arena to host memory.

@Piega
Piega force-pushed the strixhalo-host-ram-weights branch 2 times, most recently from 663462c to 8b46251 Compare September 12, 2026 21:23
Strix Halo (gfx1151) exposes a small device memory pool (~62 GiB set by the
BIOS UMA frame buffer), so a resident DeepSeek V4 Flash Q2 (80.76 GiB)
failed with OOM while preparing model tensor spans. On integrated APUs the
model arena now allocates via hipHostMalloc (fallback hipMallocManaged),
mirroring llama.cpp GGML_HIP_UMA: weights live in host RAM and stay GPU
visible over the UMA fabric, bypassing the device pool ceiling. Discrete
GPUs are unchanged; DS4_ROCM_FORCE_DEVICE_MEM restores previous behavior.

Verified on Bosgame M5 (Ryzen AI Max+ 395, Radeon 8060S, 128 GB, ROCm 10):
80.76 GiB resident in ~30 s, prefill ~273-284 tok/s (ctx 4-8k), steady
generation ~13 tok/s.
@Piega
Piega force-pushed the strixhalo-host-ram-weights branch from 8b46251 to c8b47e5 Compare September 12, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant