llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Misc. bug: larger model loading on ROCm hangs

Open de-wim opened this issue 9 months ago • 16 comments

Name and Version

$ ./bin/llama-cli --version
ggml_cuda_init: found 1 ROCm devices:
  Device 0: Radeon 8060S Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32
version: 7979 (820ebfa6f)
built with GNU 15.2.1 for Linux x86_64

Operating systems

Linux

Which llama.cpp modules do you know to be affected?

llama-server

Command line

./bin/llama-server -m ~/.cache/llama.cpp/bartowski_stepfun-ai_Step-3.5-Flash-GGUF_stepfun-ai_Step-3.5-Flash-Q3_K_S_stepfun-ai_Step-3.5-Flash-Q3_K_S-00001-of-00003.gguf -ctk q8_0 -ctv q8_0

Problem description & steps to reproduce

Loading large models with the ROCm backend hangs on my device. It loads in to memory (I can see memory usage grow) but it slows down as more memory is allocated and eventually just hangs. Or maybe slows down to a point where progress is so glacial I cannot observe it in a reasonable time. This bug only seems to affect larger models.

The following models exhibit this behaviour:

  • MiniMax M2.1 (mradermacher/MiniMax-M2.1-i1-GGUF:IQ3_XXS, ~82GB in weights)
  • Step 3.5 flash (bartowski/stepfun-ai_Step-3.5-Flash-GGUF:Q3_K_S, ~80GB)
  • PrimeIntellect INTELLECT-3 (bartowski/PrimeIntellect_INTELLECT-3-GGUF:Q5_K_S, ~71GB)
  • Qwen3-Next-80B-A3B-Instruct (Qwen/Qwen3-Next-80B-A3B-Instruct-GGUF:Q6_K, ~61GB)
  • GLM-4.6V (unsloth/GLM-4.6V-GGUF:Q4_K_XL, ~61GB)

Loading does not finish and it seems to be using between 1.7-2.0 CPU cores once stuck.

The following models load and run correctly on ROCm:

  • gpt-oss-120b (mradermacher/gpt-oss-120b-Derestricted-i1-GGUF, ~60GB - slows down a lot near the end)
  • GLM 4.7 Flash (unsloth/GLM-4.7-Flash-GGUF:Q8_K_XL, ~33GB - loads quickly)

All of these models load and run correctly using the Vulkan backend.

Additional info

I also tried some models with the CUDA backend and ZLUDA, which exhibited the same behaviour - smaller models load correctly, but loading larger models slows down until it seems to hang entirely.

I was curious and decided to dump the backtrace of the llama-server once it hung while loading, perhaps this is useful to anyone trying to figure this out:

#0  0x00007f760fe6f24e in ?? () from /opt/rocm/lib/libhsa-runtime64.so.1
#1  0x00007f760fe6f3a0 in ?? () from /opt/rocm/lib/libhsa-runtime64.so.1
#2  0x00007f760fe72241 in ?? () from /opt/rocm/lib/libhsa-runtime64.so.1
#3  0x00007f7640a948cb in ?? () from /opt/rocm/lib/libamdhip64.so.7
#4  0x00007f7640a95fb8 in ?? () from /opt/rocm/lib/libamdhip64.so.7
#5  0x00007f7640ad51ed in ?? () from /opt/rocm/lib/libamdhip64.so.7
#6  0x00007f7640ad5db1 in ?? () from /opt/rocm/lib/libamdhip64.so.7
#7  0x00007f7640ad6242 in ?? () from /opt/rocm/lib/libamdhip64.so.7
#8  0x00007f7640a99208 in ?? () from /opt/rocm/lib/libamdhip64.so.7
#9  0x00007f7640a65cfd in ?? () from /opt/rocm/lib/libamdhip64.so.7
#10 0x00007f76407de48c in ?? () from /opt/rocm/lib/libamdhip64.so.7
#11 0x00007f76407def9f in ?? () from /opt/rocm/lib/libamdhip64.so.7
#12 0x00007f76408262b1 in ?? () from /opt/rocm/lib/libamdhip64.so.7
#13 0x00007f76563c9bb0 in ggml_backend_cuda_buffer_set_tensor (buffer=<optimized out>, tensor=0x563e01a8f550, data=0x7f61fb8aee80, offset=<optimized out>, size=648806400)
    at /home/wim/src/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu:631
#14 0x00007f7656d1dcb1 in llama_model_loader::load_all_data (this=this@entry=0x7fff29f75c50, ctx=<optimized out>, bufs=..., lmlocks=<optimized out>, progress_callback=<optimized out>, 
    progress_callback_user_data=<optimized out>) at /home/wim/src/llama.cpp/src/llama-model-loader.cpp:1121
#15 0x00007f7656d73466 in llama_model::load_tensors (this=this@entry=0x563dfffd95f0, ml=...) at /home/wim/src/llama.cpp/src/llama-model.cpp:7382
#16 0x00007f7656c91ce4 in llama_model_load (fname="/home/wim/.cache/llama.cpp/bartowski_stepfun-ai_Step-3.5-Flash-GGUF_stepfun-ai_Step-3.5-Flash-Q3_K_S_stepfun-ai_Step-3.5-Flash-Q3_K_S-00001-of-00003.gguf", 
    splits=std::vector of length 3, capacity 4 = {...}, model=..., params=...) at /home/wim/src/llama.cpp/src/llama.cpp:871
#17 llama_model_load_from_file_impl (path_model="/home/wim/.cache/llama.cpp/bartowski_stepfun-ai_Step-3.5-Flash-GGUF_stepfun-ai_Step-3.5-Flash-Q3_K_S_stepfun-ai_Step-3.5-Flash-Q3_K_S-00001-of-00003.gguf", 
    splits=std::vector of length 3, capacity 4 = {...}, params=...) at /home/wim/src/llama.cpp/src/llama.cpp:1006
#18 0x00007f7656c9265b in llama_model_load_from_file (
    path_model=0x563dffdcae10 "/home/wim/.cache/llama.cpp/bartowski_stepfun-ai_Step-3.5-Flash-GGUF_stepfun-ai_Step-3.5-Flash-Q3_K_S_stepfun-ai_Step-3.5-Flash-Q3_K_S-00001-of-00003.gguf", params=...)
    at /usr/include/c++/15.2.1/bits/basic_string.tcc:248
#19 0x0000563dd9d99d28 in common_init_result::common_init_result (this=0x563dffdd0c20, params=...) at /usr/include/c++/15.2.1/bits/basic_string.h:238
#20 0x0000563dd9d9c116 in common_init_from_params (params=...) at /home/wim/src/llama.cpp/common/common.cpp:1215
#21 0x0000563dd9c8fdf7 in server_context_impl::load_model (this=0x563dffdf6970, params=...) at /home/wim/src/llama.cpp/tools/server/server-context.cpp:625
#22 0x0000563dd9c673a8 in server_context::load_model (this=this@entry=0x7fff29f78218, params=...) at /home/wim/src/llama.cpp/tools/server/server-context.cpp:2862
#23 0x0000563dd9be4556 in main (argc=<optimized out>, argv=0x7fff29f7e808) at /home/wim/src/llama.cpp/tools/server/server.cpp:248

System information:

  • ROCm version 7.2.0
  • Linux version 6.18.9

First Bad Commit

This is the first time I'm using llama.cpp with ROCm on this platform in months.

Relevant log output

Logs
./bin/llama-server -m ~/.cache/llama.cpp/unsloth_GLM-4.6V-GGUF_UD-Q4_K_XL_GLM-4.6V-UD-Q4_K_XL-00001-of-00002.gguf -ctk q8_0 -ctv q8_0
ggml_cuda_init: found 1 ROCm devices:
  Device 0: Radeon 8060S Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32
main: n_parallel is set to auto, using n_parallel = 4 and kv_unified = true
build: 7979 (820ebfa6f) with GNU 15.2.1 for Linux x86_64
system info: n_threads = 16, n_threads_batch = 16, total_threads = 32

system_info: n_threads = 16 (n_threads_batch = 16) / 32 | ROCm : NO_VMM = 1 | PEER_MAX_BATCH_SIZE = 128 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX_VNNI = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | AVX512 = 1 | AVX512_VBMI = 1 | AVX512_VNNI = 1 | AVX512_BF16 = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 | 

Running without SSL
init: using 31 threads for HTTP server
start: binding port with default address family
main: loading model
srv    load_model: loading model '/home/wim/.cache/llama.cpp/unsloth_GLM-4.6V-GGUF_UD-Q4_K_XL_GLM-4.6V-UD-Q4_K_XL-00001-of-00002.gguf'
common_init_result: fitting params to device memory, for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on
llama_params_fit_impl: projected to use 75037 MiB of device memory vs. 120451 MiB of free device memory
llama_params_fit_impl: will leave 45414 >= 1024 MiB of free device memory, no changes needed
llama_params_fit: successfully fit params to free device memory
llama_params_fit: fitting params to free memory took 0.25 seconds
llama_model_load_from_file_impl: using device ROCm0 (Radeon 8060S Graphics) (0000:c3:00.0) - 120454 MiB free
llama_model_loader: additional 1 GGUFs metadata loaded.
llama_model_loader: loaded meta data with 62 key-value pairs and 780 tensors from /home/wim/.cache/llama.cpp/unsloth_GLM-4.6V-GGUF_UD-Q4_K_XL_GLM-4.6V-UD-Q4_K_XL-00001-of-00002.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = glm4moe
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                     general.sampling.top_k i32              = 2
llama_model_loader: - kv   3:                     general.sampling.top_p f32              = 0.600000
llama_model_loader: - kv   4:                      general.sampling.temp f32              = 0.800000
llama_model_loader: - kv   5:                               general.name str              = Glm-4.6V
llama_model_loader: - kv   6:                           general.finetune str              = 4.6V
llama_model_loader: - kv   7:                           general.basename str              = Glm-4.6V
llama_model_loader: - kv   8:                       general.quantized_by str              = Unsloth
llama_model_loader: - kv   9:                         general.size_label str              = 128x8.0B
llama_model_loader: - kv  10:                            general.license str              = mit
llama_model_loader: - kv  11:                           general.repo_url str              = https://huggingface.co/unsloth
llama_model_loader: - kv  12:                   general.base_model.count u32              = 1
llama_model_loader: - kv  13:                  general.base_model.0.name str              = GLM 4.6V
llama_model_loader: - kv  14:          general.base_model.0.organization str              = Zai Org
llama_model_loader: - kv  15:              general.base_model.0.repo_url str              = https://huggingface.co/zai-org/GLM-4.6V
llama_model_loader: - kv  16:                               general.tags arr[str,2]       = ["unsloth", "image-text-to-text"]
llama_model_loader: - kv  17:                          general.languages arr[str,2]       = ["zh", "en"]
llama_model_loader: - kv  18:                        glm4moe.block_count u32              = 46
llama_model_loader: - kv  19:                     glm4moe.context_length u32              = 131072
llama_model_loader: - kv  20:                   glm4moe.embedding_length u32              = 4096
llama_model_loader: - kv  21:                glm4moe.feed_forward_length u32              = 10944
llama_model_loader: - kv  22:               glm4moe.attention.head_count u32              = 96
llama_model_loader: - kv  23:            glm4moe.attention.head_count_kv u32              = 8
llama_model_loader: - kv  24:            glm4moe.rope.dimension_sections arr[i32,4]       = [8, 12, 12, 0]
llama_model_loader: - kv  25:                     glm4moe.rope.freq_base f32              = 500000.000000
llama_model_loader: - kv  26:   glm4moe.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  27:                  glm4moe.expert_used_count u32              = 8
llama_model_loader: - kv  28:                 glm4moe.expert_group_count u32              = 1
llama_model_loader: - kv  29:            glm4moe.expert_group_used_count u32              = 1
llama_model_loader: - kv  30:               glm4moe.attention.key_length u32              = 128
llama_model_loader: - kv  31:             glm4moe.attention.value_length u32              = 128
llama_model_loader: - kv  32:               glm4moe.rope.dimension_count u32              = 64
llama_model_loader: - kv  33:                       glm4moe.expert_count u32              = 128
llama_model_loader: - kv  34:         glm4moe.expert_feed_forward_length u32              = 1408
llama_model_loader: - kv  35:                glm4moe.expert_shared_count u32              = 1
llama_model_loader: - kv  36:          glm4moe.leading_dense_block_count u32              = 1
llama_model_loader: - kv  37:                 glm4moe.expert_gating_func u32              = 2
llama_model_loader: - kv  38:               glm4moe.expert_weights_scale f32              = 1.000000
llama_model_loader: - kv  39:                glm4moe.expert_weights_norm bool             = true
llama_model_loader: - kv  40:               glm4moe.nextn_predict_layers u32              = 0
llama_model_loader: - kv  41:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  42:                         tokenizer.ggml.pre str              = glm4
llama_model_loader: - kv  43:                      tokenizer.ggml.tokens arr[str,151552]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  44:                  tokenizer.ggml.token_type arr[i32,151552]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  45:                      tokenizer.ggml.merges arr[str,318088]  = ["Ġ Ġ", "Ġ ĠĠĠ", "ĠĠ ĠĠ", "...
llama_model_loader: - kv  46:                tokenizer.ggml.eos_token_id u32              = 151329
llama_model_loader: - kv  47:            tokenizer.ggml.padding_token_id u32              = 151330
llama_model_loader: - kv  48:                tokenizer.ggml.bos_token_id u32              = 151331
llama_model_loader: - kv  49:                tokenizer.ggml.eot_token_id u32              = 151336
llama_model_loader: - kv  50:            tokenizer.ggml.unknown_token_id u32              = 151329
llama_model_loader: - kv  51:                tokenizer.ggml.eom_token_id u32              = 151338
llama_model_loader: - kv  52:                    tokenizer.chat_template str              = {# Unsloth template fixes #}\n[gMASK]<...
llama_model_loader: - kv  53:               general.quantization_version u32              = 2
llama_model_loader: - kv  54:                          general.file_type u32              = 15
llama_model_loader: - kv  55:                      quantize.imatrix.file str              = GLM-4.6V-GGUF/imatrix_unsloth.gguf
llama_model_loader: - kv  56:                   quantize.imatrix.dataset str              = unsloth_calibration_GLM-4.6V.txt
llama_model_loader: - kv  57:             quantize.imatrix.entries_count u32              = 502
llama_model_loader: - kv  58:              quantize.imatrix.chunks_count u32              = 90
llama_model_loader: - kv  59:                                   split.no u16              = 0
llama_model_loader: - kv  60:                        split.tensors.count i32              = 780
llama_model_loader: - kv  61:                                split.count u16              = 2
llama_model_loader: - type  f32:  321 tensors
llama_model_loader: - type q5_0:   33 tensors
llama_model_loader: - type q5_1:   13 tensors
llama_model_loader: - type q8_0:   45 tensors
llama_model_loader: - type q4_K:  334 tensors
llama_model_loader: - type q5_K:   23 tensors
llama_model_loader: - type q6_K:   11 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = Q4_K - Medium
print_info: file size   = 60.95 GiB (4.90 BPW) 
load: 0 unused tokens
load: special_eot_id is not in special_eog_ids - the tokenizer config may be incorrect
load: special_eom_id is not in special_eog_ids - the tokenizer config may be incorrect
load: printing all EOG tokens:
load:   - 151329 ('<|endoftext|>')
load:   - 151336 ('<|user|>')
load:   - 151338 ('<|observation|>')
load: special tokens cache size = 36
load: token to piece cache size = 0.9713 MB
print_info: arch                  = glm4moe
print_info: vocab_only            = 0
print_info: no_alloc              = 0
print_info: n_ctx_train           = 131072
print_info: n_embd                = 4096
print_info: n_embd_inp            = 4096
print_info: n_layer               = 46
print_info: n_head                = 96
print_info: n_head_kv             = 8
print_info: n_rot                 = 64
print_info: n_swa                 = 0
print_info: is_swa_any            = 0
print_info: n_embd_head_k         = 128
print_info: n_embd_head_v         = 128
print_info: n_gqa                 = 12
print_info: n_embd_k_gqa          = 1024
print_info: n_embd_v_gqa          = 1024
print_info: f_norm_eps            = 0.0e+00
print_info: f_norm_rms_eps        = 1.0e-05
print_info: f_clamp_kqv           = 0.0e+00
print_info: f_max_alibi_bias      = 0.0e+00
print_info: f_logit_scale         = 0.0e+00
print_info: f_attn_scale          = 0.0e+00
print_info: n_ff                  = 10944
print_info: n_expert              = 128
print_info: n_expert_used         = 8
print_info: n_expert_groups       = 1
print_info: n_group_used          = 1
print_info: causal attn           = 1
print_info: pooling type          = 0
print_info: rope type             = 8
print_info: rope scaling          = linear
print_info: freq_base_train       = 500000.0
print_info: freq_scale_train      = 1
print_info: n_ctx_orig_yarn       = 131072
print_info: rope_yarn_log_mul     = 0.0000
print_info: rope_finetuned        = unknown
print_info: mrope sections        = [8, 12, 12, 0]
print_info: model type            = ?B
print_info: model params          = 106.85 B
print_info: general.name          = Glm-4.6V
print_info: vocab type            = BPE
print_info: n_vocab               = 151552
print_info: n_merges              = 318088
print_info: BOS token             = 151331 '[gMASK]'
print_info: EOS token             = 151329 '<|endoftext|>'
print_info: EOT token             = 151336 '<|user|>'
print_info: EOM token             = 151338 '<|observation|>'
print_info: UNK token             = 151329 '<|endoftext|>'
print_info: PAD token             = 151330 '[MASK]'
print_info: LF token              = 198 'Ċ'
print_info: FIM PRE token         = 151347 '<|code_prefix|>'
print_info: FIM SUF token         = 151349 '<|code_suffix|>'
print_info: FIM MID token         = 151348 '<|code_middle|>'
print_info: EOG token             = 151329 '<|endoftext|>'
print_info: EOG token             = 151336 '<|user|>'
print_info: EOG token             = 151338 '<|observation|>'
print_info: max token length      = 1024
load_tensors: loading model tensors, this can take a while... (mmap = true, direct_io = false)
load_tensors: offloading output layer to GPU
load_tensors: offloading 45 repeating layers to GPU
load_tensors: offloaded 47/47 layers to GPU
load_tensors:   CPU_Mapped model buffer size =   333.00 MiB
load_tensors:        ROCm0 model buffer size = 62077.27 MiB
.............................................................................................

de-wim avatar Feb 10 '26 08:02 de-wim

Try this: llama-server -m Step-3.5-Flash-Q4_K_S/new-Q4_K_S.gguf --ctx-size 131072 --flash-attn on --no-mmap --batch-size 2048 --ubatch-size 2048 --parallel 1 --cache-ram -1 --cache-type-k f16 --cache-type-v f16 --threads -1 --seed -1 -dio

IIIIIllllIIIIIlllll avatar Feb 10 '26 09:02 IIIIIllllIIIIIlllll

Try this: llama-server -m Step-3.5-Flash-Q4_K_S/new-Q4_K_S.gguf --ctx-size 131072 --flash-attn on --no-mmap --batch-size 2048 --ubatch-size 2048 --parallel 1 --cache-ram -1 --cache-type-k f16 --cache-type-v f16 --threads -1 --seed -1 -dio

So I've been playing with options a little bit, and the following flags fix the issue:

  • Adding --no-mmap to the command (loading is faster)
  • Setting the env var GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 (loading is still slow but does not get stuck)

Not sure why this is or why it only affects large models - perhaps there is some issue with creating a larger than 64GB mmapped buffer in ROCm?

de-wim avatar Feb 10 '26 10:02 de-wim

Curious if anyone else is experiencing this and has any other workaround? Mine freezes indefinitely with no errors at "graph_reserve: reserving a graph for ubatch with n_tokens = 2048, n_seqs = 1, n_outputs = 2048" and none of the stuff in here works

xten avatar Feb 12 '26 02:02 xten

I experience the same. And with llama-bench it even freezes so bad that I cannot kill -9 the process!

jdchmiel avatar Feb 15 '26 15:02 jdchmiel

Can confirm this on the same GPU (gfx1151, Radeon 8060S / Strix Halo, 96GB VRAM).

Reproduces:

  • Qwen3.5-35B-A3B-UD-Q6_K_XL.gguf (30GB) — hangs during load_tensors, pegged at ~97% CPU
  • Qwen3.5-35B-A3B-Q8_0.gguf (37GB) — same behavior without workaround

Works fine:

  • Qwen3.5-35B-A3B-UD-Q4_K_L.gguf (19GB) — loads in ~15s

Workaround confirmed: --no-mmap fixes both — they load in ~30-45s.

johnnytshi avatar Mar 09 '26 17:03 johnnytshi

I experience the same issue with my RX 7900 XT (gfx1100)

aviallon avatar Mar 18 '26 13:03 aviallon

I have the same problem on my 6900 XT.Using --no-mmap fixes this.

js2235 avatar Mar 23 '26 18:03 js2235

i had the same problem loading Qwen 3.5 122b UD-Q6_K_XL on 4xR9700. --no-mmap fixes this.

jack10768 avatar Apr 08 '26 10:04 jack10768

For those interested, if using bcachefs, the problem gets enormously worse.

aviallon avatar Apr 08 '26 13:04 aviallon

Can confirm --no-mmap fixes it.

wsantos avatar Jun 28 '26 22:06 wsantos

I can confirm this on Strix Halo 128GB.

Using --direct-io completely fixes it.

@JohannesGaessler any ideas what could be the cause?

pwilkin avatar Jul 01 '26 19:07 pwilkin

Same failure class on gfx1151 (Radeon 8060S, Strix Halo), with kernel-side corroboration and a fully instrumented run.

Environment

  • Machine: BOSGAME BeyondMax (AXB35-02 board), Ryzen AI Max+ 395, Radeon 8060S gfx1151 (VMM: no), 128 GiB unified memory, 96 GiB static UMA carveout (BIOS)
  • OS/driver: Ubuntu 26.04 LTS, kernel 7.0.0-29-generic, in-tree amdgpu (no DKMS), ROCm 7.14.0
  • llama.cpp: commit 6ea215d171fd31df943bf1ac8227129f2b963160 (b10276), HIP backend, GGML_HIP_NO_VMM=ON, Release, GNU 15.2.0
  • Model: Llama-3.3-70B-Instruct-Q4_K_M.gguf, 42,520,398,816 bytes (~39.6 GiB), sha256 32df3baccb556f9840059b2528b2dee4d3d516b24afdfb9d0c56ff5f63e3a664

Reproducer (run twice, byte-identical, default login environment — no special env vars):

/path/to/llama-cli -m /path/to/Llama-3.3-70B-Instruct-Q4_K_M.gguf --fit off -ngl 999 -c 512 --single-turn --temp 0 -n 8 -t 12 -b 2048 -ub 512 --flash-attn auto -v -p "Reply with exactly: 70B LOAD PASS"

(--fit off only bypasses the unrelated UMA free-memory misread tracked in #18159; explicit -ngl 999 -c 512. Default mmap path in use.)

What happens (both attempts)

  1. Load proceeds normally through load_tensors: offloaded 81/81 layers to GPU, CPU_Mapped model buffer size = 563.62 MiB, ROCm0 model buffer size = 39979.48 MiB.
  2. Nothing after that, ever. Zero llama_init_from_model / llama_context lines; context construction, KV allocation, FA selection, prompt eval, generation never reached. Both runs hit an external 900 s safety cap (SIGTERM → SIGKILL, exit 137).
  3. At the post-offload transition, the kernel logs amdgpu SVM failures (see below). No GPU reset, no ring timeout, no KFD page fault, no OOM in either run window (full-boot journal scans).

Attempt 1 (host had ~2.7 GiB residual swap + page-cache pressure): silent freeze — all 38 threads parked (S state, ~0 CPU), log frozen after the offload prints. Kernel journal for the run window: 87 amdgpu SVM events — 5× svm_range_restore_work [amdgpu] hogged CPU for >10000us (escalating 4→19 times), 80× amdgpu: SVM mapping failed, exceeds resident system memory limit, 2× amdgpu: User Buffer Address: 0x70f3b80dc000 already allocated by SVM (20:13:21–20:23:10 local).

Attempt 2 (fresh reboot, clean baseline, instrumented at 1 s / 10 s cadence): live userspace spin — the load/offload worker thread ran R state, wchan -, 93.1% CPU (ps lifetime ratio; ~97.7% of one core by utime deltas) for the entire ~14.6 min post-offload window (~831 s CPU), with:

  • minor/major fault counters effectively frozen (+35 minflt / +83 majflt over the final 10 min — zero page I/O),
  • RSS 26.8 GiB flat, VmSize flat, process VmSwap ~100 MB static, device VRAM static at 39.83 GiB (of 96 GiB; FREE_VRAM was 97,714 MB preflight),
  • MemAvailable ≥ 25.2 GiB throughout; host swap flat after the page-in phase.
  • Kernel (18 events, 22:00:16–22:02:00 local): 6× svm_range_restore_work [amdgpu] hogged CPU for >10000us (escalating 4→35 times), then 11× amdgpu: SVM mapping failed, exceeds resident system memory limit, 1× amdgpu: User Buffer Address: 0x7a117c0dc000 already allocated by SVM. No equivalent SVM messages anywhere else in the boot.

So: buffer allocation and offload bookkeeping complete; tensor-data upload never completes; one thread spins in userspace in (likely) the HSA/HIP copy/sync path while the kernel reports SVM mapping failures against the ~39 GiB registered buffer. I do not have a symbolized userspace backtrace (my gdb trigger keyed on log-mtime stillness, and llama-cli's timer-driven spinner kept the mtime fresh — noted as a trigger-design miss; a spin-triggered capture is possible if useful).

How this maps to this issue

  • Same GPU class and VMM configuration; same stall locus as de-wim's backtrace (load_all_data → ggml_backend_cuda_buffer_set_tensor → libamdhip64/libhsa-runtime64); pre-inference; no fault/reset/OOM.
  • Additional reports in this issue describe similar large-model hangs and high single-thread CPU use on Radeon 8060S systems. My result adds a reproducible 39.6 GiB data point with synchronized userspace and kernel SVM telemetry.
  • Both CPU manifestations described in this thread occur for the same failure on one machine: parked/idle (attempt 1) vs single-core spin (attempt 2, matching the high-single-thread-CPU reports noted above). The kernel SVM signature is identical in both.
  • ROCm-side context: ROCm/ROCm#6182 (same AXB35-02 board family) exhausted HSA env levers, TTM/GTT settings, UMA carveouts, kernels, and ROCm versions for a sibling model-load failure class; my case is bare-metal (no container) with a different kernel signature.

Status note: issue #19482 remains open. PR #25212 was closed without merge on July 3, 2026; I am referencing its diagnosis and staged-upload approach, not claiming that its changes landed in the current llama.cpp source.

Questions / asks

  1. PR #25212 proposed routing mmap-backed ROCm model uploads through pinned staging buffers because pinning the complete mmap-backed model could trigger allocation failures and retry behavior. That PR was closed without merge while maintainers completed broader load-mode work. Does the planned successor to that approach cover this 39.6 GiB failure on gfx1151, or is there another fix branch or load-mode configuration you would prefer me to test?
  2. Are --no-mmap / --direct-io expected to route around the kernel SVM layer entirely (explaining the thread's workarounds), or is a runtime-side retry loop still involved? (I have not run them yet — test matrix is frozen pending maintainer/AMD guidance; happy to A/B on request.)
  3. Would a symbolized backtrace of the spinning thread (spin-triggered gdb/perf) and/or amdgpu SVM tracepoints during the stall help? I can capture either on this machine.
  4. Happy to test any fix candidate from #25212 or elsewhere on this exact setup and report back with the same instrumentation.

Artifacts (full timelines, thread captures, kernel event tables, environment): https://gist.github.com/Lrrr908/ab3c1d7959c50471aa150812f2741bcc#file-strix-70b-run2-forensic-report-md (run-2 forensic report), https://gist.github.com/Lrrr908/ab3c1d7959c50471aa150812f2741bcc#file-strix-70b-run2-timeline-1s-tsv (1 s timeline TSV), https://gist.github.com/Lrrr908/ab3c1d7959c50471aa150812f2741bcc#file-strix-70b-kernel-svm-events-both-runs-md (kernel SVM event tables for both runs), https://gist.github.com/Lrrr908/ab3c1d7959c50471aa150812f2741bcc#file-strix-70b-run2-thread-state-txt (thread-state capture).

Lrrr908 avatar Aug 06 '26 04:08 Lrrr908

Additional datapoints from a Strix Halo machine (Framework Desktop, Ryzen AI MAX+ 395, Radeon 8060S gfx1151, 128 GB unified LPDDR5X, Arch kernel 7.1.6, amdgpu.gttsize=96000 ttm.pages_limit=24576000), 85 GB model (DeepSeek-V4-Flash UD-IQ2_M, split GGUF), loading from NVMe:

1. It is not the IOMMU. A common community explanation for this hang on Strix Halo is the IOMMU. I tested the same load under amd_iommu=off and iommu=pt (ROCm 7.2.4, build c812c543f): the mmap-path hang reproduces identically in both IOMMU modes, and --no-mmap loads in ~23–24 s in both. One mmap run was left going: >5 h at ~99 % of one CPU in host-side memory registration (userptr path), GPU idle, before being killed.

2. Still present in ROCm 7.14. On a ROCm 7.14 toolbox with llama.cpp b10417 (2606220d9), forcing the old path with --load-mode mmap hangs the same way (no progress in 9 min, then killed).

3. The new --load-mode auto default sidesteps it. Same ROCm 7.14 container, same model, default flags: loads and runs in ~23 s (llama-bench pp16/tg8 completes). So on current builds the failure only bites when mmap is explicitly selected — consistent with earlier reports here that -dio resolves it.

Config forced mmap --no-mmap / --load-mode auto
ROCm 7.2.4, amd_iommu=off hang ~24 s
ROCm 7.2.4, iommu=pt hang (>5 h @ 99 % CPU, GPU idle) ~23 s
ROCm 7.14 (b10417), iommu=pt hang (>9 min, killed) ~23 s

So the underlying ROCm userptr-registration pathology on large mappings is unchanged; llama.cpp's new load-mode default is what makes it invisible in practice.

sravanpannala avatar Aug 13 '26 17:08 sravanpannala

Another data point, on hardware quite different from the original report: two discrete gfx1100 cards, not an APU. Same symptom, same backtrace.

System

  • GPUs: RX 7900 XTX (24 GiB, PCIe x16 Gen4) + RX 7900 XT (20 GiB, x4 Gen4), both gfx1100
  • ROCm 7.2.4, Ubuntu 24.04.4 LTS, kernel 7.0.0-30-generic, 30 GiB system RAM
  • llama.cpp 1729ed5, built GGML_HIP=ON -DAMDGPU_TARGETS=gfx1100
  • Model: Llama-3.3-70B-Instruct Q4_K_M (42,520,398,432 bytes, size verified byte-exact against upstream, valid GGUF magic). IQ4_XS (37.9 GB) hangs identically, so it is not quant-specific.

Symptom

Loading hangs partway. VRAM fills to ~90% on both cards, then one thread spins in userspace indefinitely with both GPUs at 0%. No error, no timeout, no progress. Observed for 70 minutes on one attempt.

Backtrace (rocgdb, SIGINT after 200 s)

#0-#9   libhsa-runtime64.so.1
#10-#12 libamdhip64.so.7
#13     ggml_backend_cuda_buffer_set_tensor()
#14     llama_model_loader::load_all_data()
#15     llama_model_base::load_tensors()
#16     llama_model_load()
#17     llama_model_load_from_file_impl()
#18     llama_model_load_from_file()

The main thread is parked in cli_server::wait_ready; every other thread is in futex_do_wait. Same frame as the original report, so this does not look APU- or unified-memory-specific.

It is a busy-spin, not a stall waiting on I/O or memory

Measured on the hung process:

  • read_bytes delta over 20 s: 0. Major faults 1,445. Nothing is being read from disk.
  • The spinning thread burned 103 s of CPU in 110 s of wall (~94% of one core), state=R, wchan=0, no syscall in flight.
  • System RAM steady at ~27 GiB available throughout; swap flat.

It tracks free VRAM, at a threshold nothing legitimate should need

All with -c 512:

-ngl Weights on GPU Free VRAM Result
99 40 GiB ~4 GiB hang
70 35 GiB ~9 GiB hang
62 34 GiB ~10 GiB hang
55 27 GiB ~17 GiB loads, runs at 3.3 t/s

The compute buffers are not what needs that room. From the load log: ROCm0 282.04 MiB, ROCm1 346.04 MiB, ROCm_Host 34.05 MiB. Forcing -b 128 -ub 128 -fa on made no difference — still hung the full 420 s. A 17.28 GiB model (Qwen3-30B-A3B Q4_K_M) loads and runs fine on the same build and the same two cards, so this only shows up when free VRAM gets low.

Vulkan runs the same file on the same machine

Consistent with the original report. Using the upstream b10636 Vulkan release binary, no rebuild, on the same two cards: the identical 70B GGUF loads and generates at 13.6 t/s (prompt 99.4 t/s) with all 80 layers offloaded. Only the HIP backend hangs.

Happy to run further diagnostics on this setup if any would be useful — I can reproduce it on demand in about 90 seconds.

thtein avatar Aug 26 '26 16:08 thtein

Thanks to the maintainers and to everyone who already reported here. I'm a curious user, not a ROCm or llama.cpp expert. This is a personal lab on a low-end laptop: not meant for production and not tested beyond this machine.

AI was used throughout: AI agents did the research (issues and other projects' code), wrote the test code, ran the tests on my machine, and drafted this text from my notes; I reviewed it and the numbers come from my machine. It was trial and error, I don't understand every cause, and I may be wrong. Please treat this as a lead, not a fix. Corrections are welcome.

Another data point, from a small APU, with a workaround that keeps mmap enabled. The suggestions in this thread so far turn mmap off (--no-mmap, --direct-io); this one doesn't.

The problem. On my machine (Radeon 610M, ROCm 7.1, gpt-oss-20b with mmap on), loading the model:

  • stalled between 40% and 99% for 13 to 30 minutes, sometimes forever;
  • kept one thread at 100% inside libhsa-runtime64 while the GPU sat idle;
  • filled the kernel log with:
    workqueue: svm_range_restore_work [amdgpu] hogged CPU for >10000us 2051 times
    workqueue: amdgpu_amdkfd_restore_userptr_worker [amdgpu] hogged CPU for >10000us 515 times
    
  • and, with RAM tight, froze the whole machine (hard reboot).

What fixed it. Setting these three variables before the HIP runtime starts:

GGML_CUDA_NO_PINNED=1
HSA_USERPTR_FOR_PAGED_MEM=0
GPU_PINNED_MIN_XFER_SIZE=1048576

Why it works (my understanding — please correct me). For each host-to-device copy, the HIP runtime registers the program's pageable memory (userptr). When the kernel moves those pages, the driver stops and rebuilds every GPU queue of the process — that is the loop in the log. With the variables, copies go through the runtime's own staging buffers and the program's pages are not registered.

Where it came from. I did not find this myself: the Strata project documents both HSA/HIP variables, the cases they fixed, and the queue eviction (links below).

Numbers. Each run: page cache dropped first, 150-token prompt, 16 generated tokens, one run each (so expect noise). "GPU up to" is the memory budget given to llama.cpp's automatic fit.

GPU up to Variables Result Prompt (tok/s) Generation (tok/s)
5 GiB none completed, slow 3.2 0.15
5 GiB GGML_CUDA_NO_PINNED only completed 7.4 0.68
6 GiB none stalled in compute — —
7 GiB none machine froze — —
6 GiB all three 66 s 11.1 2.45
7 GiB all three 57 s 13.5 2.92
8 GiB all three 63 s 12.6 2.43
9 GiB all three 60 s 15.2 2.79
10 GiB (GTT size) all three 116 s 16.1 3.33

With all three: zero loop warnings in the kernel log, from 6 to 10 GiB. The "none" and "NO_PINNED only" rows were measured earlier with older versions of my code; the "all three" rows on 2026-11-18.

Limitations. One machine, one model, one run each; old ROCm (Ubuntu packages) with a gfx override; I did not test discrete GPUs or the Strix Halo setups in this thread; I don't know whether HSA_USERPTR_FOR_PAGED_MEM=0 costs anything elsewhere.

Ask. If someone with the original reporter's hardware can try the variables with mmap left on, it would show whether the root cause is the same.

How I set the variables (before the HIP runtime starts)
// Before the HIP runtime starts; a value the user already set wins.
fn tune_apu() {
    if !has_amd_apu() { return; } // /sys/class/drm/card*/device/mem_info_vram_total < 2 GiB
    for (k, v) in [
        ("GGML_CUDA_NO_PINNED", "1"),
        ("HSA_USERPTR_FOR_PAGED_MEM", "0"),
        ("GPU_PINNED_MIN_XFER_SIZE", "1048576"),
    ] {
        if std::env::var_os(k).is_none() { std::env::set_var(k, v); }
    }
}

Same thing with llama-server:

GGML_CUDA_NO_PINNED=1 HSA_USERPTR_FOR_PAGED_MEM=0 GPU_PINNED_MIN_XFER_SIZE=1048576 \
  llama-server -m gpt-oss-20b-MXFP4.gguf

Links (what came from where)

  1. Strata (MIT, version 0.1.61, commit c775728, 2026-11-16):
  2. llama.cpp today (master, commit 2cbfc3c, 2026-11-18): where GGML_CUDA_NO_PINNED is read — ggml/src/ggml-cuda/ggml-cuda.cu, line 170.
  3. llama.cpp used in the tests (commit d812350): the same variable there — ggml-cuda.cu, line 1274 and line 5219.
  4. Model: ggml-org/gpt-oss-20b-GGUF.
Unit tests (23 passed, 2026-11-18)

Pure logic, no GPU: cargo test --release -j1 -p busca --no-default-features --features rocm --lib → 23 passed; 0 failed, run twice. The measurements in the tables are a different thing: real runs, one each.

Test What it checks
apu_budget_and_cap APU budget (carveout + GTT) vs discrete card, the iGPU cap, the false "available" peak right after another process exits, gfx override from the KFD gfx_target_version
gpu_ram_disk_split the GPU / fit / experts-in-RAM / CPU decision
ssd_manager_names tensor names blk.N.ffn_*_exps.weight and graph node ffn_moe_topk-N
ssd_manager_ceiling RAM ceiling for experts read from the mmap (70 % of available, minimum 512 MiB)
lru_respects_ceiling LRU over a real mmap gives back the oldest expert and never the layer in use
proc_reading, monitor_stops_on_drop the /proc reader (disk, CPU, RAM) and the monitor thread stopping
16 older tests log parsing, UTF-8, KV cache types

Behaviour test of the safety guard: with the swap limit set to 1 MiB the process exits with code 137, no segfault.

The tests behind the numbers in these comments (function names translated from Portuguese):

#[test]
fn apu_budget_and_cap() {
    const M: u64 = 1024 * 1024;
    // Radeon 610M: 512 MiB carveout + 10 GiB GTT -> 85 % of the sum
    assert_eq!(budget_from(512 * M, 10240 * M), (512 + 10240) * M / 100 * 85);
    // 12 GiB discrete card: only its VRAM counts
    assert_eq!(budget_from(12288 * M, 16000 * M), 12288 * M / 100 * 85);
    // gfx override read from the KFD gfx_target_version
    assert_eq!(gfx_override_for(100306), Some("10.3.0")); // gfx1036
    assert_eq!(gfx_override_for(100300), None);           // a real gfx1030
    assert_eq!(gfx_override_for(110003), None);           // RDNA3
    // 2026-11-18: 5 GiB available and a 3 GiB reserve leave 2 GiB for the iGPU
    assert_eq!(cap(5 * 1024 * M, 3072 * M, None, 35), 2048 * M);
    assert_eq!(cap(1024 * M, 3072 * M, None, 35), 0);
    // false peak right after another process exits: 9.6 GiB "available" on 14.4 GiB -> the fraction wins
    let total = 14746 * M;
    assert_eq!(cap(9830 * M, 3072 * M, Some(total), 35), total / 100 * 35);
}

#[test]
fn gpu_ram_disk_split() {
    const G: u64 = 1024 * 1024 * 1024;
    // auto: 11 GiB model, 8 GiB budget -> llama.cpp fit (GPU first, the rest in RAM)
    assert_eq!(decide("auto", true, 11 * G, Some(8 * G)), Fit);
    // auto: it fits -> all on the GPU
    assert_eq!(decide("auto", true, 2 * G, Some(8 * G)), Gpu);
    // auto with an unknown budget -> don't guess
    assert_eq!(decide("auto", true, 11 * G, None), Gpu);
    // no GPU, even when forced
    assert_eq!(decide("on", false, 11 * G, Some(8 * G)), Cpu);
    assert_eq!(decide("on", true, 1, Some(8 * G)), ExpertsInRam);
    assert_eq!(decide("off", true, 11 * G, Some(G)), Gpu);
}
Environment (full versions)
  • OS: Ubuntu 26.04 LTS, Linux kernel 7.0.0-43-generic (package linux-image-7.0.0-43-generic 7.0.0-43.43), amdgpu driver 3.64.0.
  • Firmware: linux-firmware-amd-graphics 20260319.git217ca6e4-0ubuntu3.1; DMUB 0x06001300; VBIOS 102-MENDOCINO-006.
  • Kernel parameter: ttm.pages_limit=2621440 (10 GiB GTT) — ttm.pages_limit in the kernel docs.
  • ROCm (Ubuntu packages): HIP 7.1.52801 (libamdhip64-7 7.1.0-0ubuntu2, hipcc 7.1.1+dfsg-0ubuntu1); libhsa-runtime64-1 7.1.0+dfsg-0ubuntu9; libhsakmt1 7.1.0+dfsg-0ubuntu9; librocblas5 7.1.0-1ubuntu4; libhipblas3 7.1.0-0ubuntu5; rocminfo 7.1.1-0ubuntu1.
  • Compilers: clang-21 1:21.1.8-6ubuntu1; Rust 1.97.1; CMake 4.2.3.
  • Hardware: ASUS Vivobook Go E1504FA (BIOS E1504FA.317); Ryzen 5 7520U; Radeon 610M 1002:1506 (gfx1036, 2 CUs, up to 1899 MHz); 2 × 8 GB LPDDR5-5500; clocks at power_dpm_force_performance_level=high.
  • llama.cpp used in the tests: the one bundled by the Rust crate llama-cpp-sys-2 0.1.161 (llama-cpp-rs, commit e7af607), which ships llama.cpp at commit d812350; HIP build for gfx1030, run with HSA_OVERRIDE_GFX_VERSION=10.3.0.
  • Model: gpt-oss-20b-MXFP4.gguf (12,109,566,624 bytes, sha256 27cd6c432c7672cb812a92f611cf3ba7bbc35928262bb1e1253ff4ee6ae35901).
  • Automated tests of my code: 23 passed (18/11/2026). They test the logic (memory limits, GPU/RAM decision, /proc parsing), without a GPU. The tables above are a different thing: real runs, one each.

programandosolucoes avatar Nov 19 '26 14:11 programandosolucoes

The ROCm side of this case is reported in ROCm/rocm-systems#15955: https://github.com/ROCm/rocm-systems/issues/15955#issuecomment-7012656131.

programandosolucoes avatar Nov 19 '26 14:11 programandosolucoes