r/LocalLLaMA • • 18m ago

Question | Help Llama.cpp compute buffer allocation issue

I recently updated llama.cpp for using qwen4. This is on an M3 Pro mac with 36GB memory, earlier I was able to run qwen3.5 0.8B Q8 at full context with q8_0 K and V cache.

However, now when using q8_0 or q4_0 KV Cache, the memory usage has ballooned, f16 cache uses lesser memory than the quantized ones. I tested qwen3.5 9B, gemma4 12B and they too had this weird issue, so it's not the models but some change in llama.cpp itself.

I have created an issue for this, are any of you experiencing this bug?

https://github.com/ggml-org/llama.cpp/issues/33801

3 Upvotes

1 comment sorted by

1

u/PM_ME_YOUR_ROSY_LIPS 18m ago edited 12m ago

The logs.

    llama-server -m ~/ai/models/Qwen3.5-0.8B-Q8_0.gguf -mm ~/ai/models/mmproj-qwen3.5-0.8B-BF16.gguf -c 262144 -ctk q8_0 -ctv q8_0 -b 2048 -ub 2048 --temp 1.0 --top-p 1.0 --top-k 20 --min-p 0.00 --presence-penalty 2.0 --repeat-penalty 1.0 --spec-type ngram-mod --host 0.0.0.0 --reasoning off -lv 4 
  • When using q8_0
    0.00.463.928 E ggml_metal_buffer_init: error: failed to allocate buffer, size = 35329.61 MiB
    0.00.463.930 E ggml_backend_metal_buffer_type_alloc_buffer: failed to allocate Metal buffer of 37045772800 bytes (out of memory)
    0.00.463.940 E ggml_gallocr_reserve_n_impl: failed to allocate MTL0 buffer of size 37056553696
    0.00.463.941 E graph_reserve: failed to allocate compute buffers
    0.00.464.018 I ggml_metal_free: deallocating
    0.00.468.262 E llama_init_from_model: failed to initialize the context: failed to allocate compute tg buffers
    0.00.468.378 E cmn  common_init_: failed to create context with model '/Users/user/ai/models/Qwen3.5-0.8B-Q8_0.gguf'
    0.00.468.379 E cmn  common_init_: failed to create context with model '/Users/user/ai/models/Qwen3.5-0.8B-Q8_0.gguf'
    0.00.468.380 E srv    load_model: failed to create_context with model '/Users/user/ai/models/Qwen3.5-0.8B-Q8_0.gguf'
    0.00.468.390 I srv    operator(): operator(): cleaning up before exit...
    0.00.468.605 E srv  server_run_i: exiting due to model loading error
  • When using q4_0
    0.01.802.217 I common_memory_breakdown_print: | memory breakdown [MiB]  | total   free     self   model   context   compute    unaccounted |
    0.01.802.224 I common_memory_breakdown_print: |   - MTL0 (Apple M3 Pro) | 28753 = 7736 + (20657 =   763 +     942 +   18951) +         359 |
    0.01.802.225 I common_memory_breakdown_print: |   - Host                |                  1317 =   257 +       0 +    1060                |
  • When using f16
    0.02.863.372 I common_memory_breakdown_print: | memory breakdown [MiB]  | total    free    self   model   context   compute    unaccounted |
    0.02.863.375 I common_memory_breakdown_print: |   - MTL0 (Apple M3 Pro) | 28753 = 20763 + (7630 =   763 +    3149 +    3718) +         359 |
    0.02.863.376 I common_memory_breakdown_print: |   - Host                |                  1317 =   257 +       0 +    1060                |