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

Eval bug: server crash when processing large image with >4B Qwen3.5 and Qwen3-VL models

Open CatKasha opened this issue 7 months ago • 5 comments

Name and Version

version: 8708 (ae65fbdf3) built with Clang 19.1.5 for Windows x86_64

Operating systems

Windows

GGML backends

Vulkan

Hardware

ryzen 3700x, radeon rx6600

Models

No response

Problem description & steps to reproduce

server crash when processing large image with >4B Qwen3.5 and Qwen3-VL models also noticed when processing image larger than 1024x gpu can freeze couple times, with gemma4 its not that noticeable

with --flash-attn off everything works but when processing >1024x images server start eat almost all ram, encoding image slice take long time (done on cpu) and then decoding image done on gpu

test images are white png with 1024x1024, 2048x2048, 4096x4096, 8192x8192 res tested with --n-gpu-layers 0 so mmproj can fit to gpu launch option:

.\bin\llama-server.exe ^
-m       .gguf ^
--mmproj .gguf ^
--jinja ^
--n-gpu-layers 0 ^
--ctx-size 16384 ^
-fit off
build ver unsloth, mmproj-F16 1024 2048 4096 8192
8708 Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-4B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok fail
Qwen3-VL-30B-A3B-Instruct-UD-IQ1_S.gguf ok fail
Qwen3-VL-32B-Instruct-UD-IQ1_S.gguf ok fail
Qwen3.5-0.8B-UD-IQ2_XXS.gguf ok ok ok ok
Qwen3.5-2B-UD-IQ2_XXS.gguf ok ok ok ok
Qwen3.5-4B-UD-IQ2_XXS.gguf ok ok ok ok
Qwen3.5-9B-UD-IQ2_XXS.gguf ok fail
Qwen3.5-27B-UD-IQ2_XXS.gguf ok fail
Qwen3.5-35B-A3B-UD-IQ2_XXS.gguf ok fail
bartowski, mmproj-F16
Qwen_Qwen3.5-9B-IQ2_S.gguf ok fail
lmstudio, mmproj-BF16
Qwen3.5-9B-Q4_K_M.gguf ok fail

First Bad Commit

did some manual bisect of prebuilds, idk if that helps 6915 and 6924 give this error when crash:

Logs
srv  params_from_: Chat format: Hermes 2 Pro
slot get_availabl: id  0 | task -1 | selected slot by LRU, t_last = -1
slot launch_slot_: id  0 | task 1 | processing task
slot update_slots: id  0 | task 1 | new prompt, n_ctx_slot = 16384, n_keep = 0, task.n_tokens = 2035
slot update_slots: id  0 | task 1 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id  0 | task 1 | prompt processing progress, n_tokens = 4, batch.n_tokens = 4, progress = 0.001966
slot update_slots: id  0 | task 1 | n_tokens = 4, memory_seq_rm [4, end)
srv  process_chun: processing image...
encoding image slice...
ggml_vulkan: Device memory allocation of size 4199040000 failed.
ggml_vulkan: Requested buffer size exceeds device buffer size limit: ErrorOutOfDeviceMemory
ggml_gallocr_reserve_n: failed to allocate Vulkan0 buffer of size 8655336000
D:/a/llama.cpp/llama.cpp/ggml/src/ggml-backend.cpp:1851: GGML_ASSERT((char *)addr + ggml_backend_buffer_get_alloc_size(buffer, tensor) <= (char *)ggml_backend_buffer_get_base(buffer) + ggml_backend_buffer_get_size(buffer)) failed

in 6927 gpu freeze appears

build ver unsloth, mmproj-F16 1024 2048 4096 8192
6887 (d261223d2) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok ok ok ok
6912 (961660b8c) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok ok
no builds between
6915 (cf659bbb8) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok fail
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok fail
6924 (87c9efc3b) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok fail fail
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok fail fail
no builds between
6927 (6b9a52422) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok ok
Qwen3-VL-32B-Instruct-UD-IQ1_S.gguf ok ok
6958 (13b339bcd) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok ok ok ok
Qwen3-VL-32B-Instruct-UD-IQ1_S.gguf ok ok
6959 (92bb84f77) Qwen3-VL-2B-Instruct-UD-IQ1_S.gguf ok ok fail
Qwen3-VL-4B-Instruct-UD-IQ1_S.gguf ok ok fail
Qwen3-VL-8B-Instruct-UD-IQ1_S.gguf ok fail

Relevant log output

Logs
srv  params_from_: Chat format: peg-native
slot get_availabl: id  3 | task -1 | selected slot by LRU, t_last = -1
srv  get_availabl: updating prompt cache
[0msrv          load:  - looking for better prompt, base f_keep = -1.000, sim = 0.000
[0msrv        update:  - cache state: 0 prompts, 0.000 MiB (limits: 8192.000 MiB, 16384 tokens, 8589934592 est)
[0msrv  get_availabl: prompt cache update took 0.02 ms
[0mslot launch_slot_: id  3 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id  3 | task 0 | processing task, is_child = 0
slot update_slots: id  3 | task 0 | new prompt, n_ctx_slot = 16384, n_keep = 0, task.n_tokens = 4108
slot update_slots: id  3 | task 0 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id  3 | task 0 | prompt processing progress, n_tokens = 4, batch.n_tokens = 4, progress = 0.000974
srv  log_server_r: done request: POST /v1/chat/completions 127.0.0.1 200
slot update_slots: id  3 | task 0 | n_tokens = 4, memory_seq_rm [4, end)
srv  process_chun: processing image...
encoding image slice...

CatKasha avatar Apr 10 '26 22:04 CatKasha

updated First Bad Commit section

CatKasha avatar Apr 12 '26 11:04 CatKasha

tested in ubuntu 25.10 live cd (Mesa 25.2.3), b8830 prebuilt Qwen3-VL 2B, 4B, 8B, 32B works fine

CatKasha avatar Apr 17 '26 19:04 CatKasha

Ok bro

في الجمعة، 17 أبريل 2026 20:25 CatKasha @.***> كتب:

CatKasha left a comment (ggml-org/llama.cpp#21750) https://github.com/ggml-org/llama.cpp/issues/21750#issuecomment-4270703787

tested in ubuntu 25.10 live cd (Mesa 25.2.3), b8830 prebuilt Qwen3-VL 2B, 4B, 8B, 32B works fine

— Reply to this email directly, view it on GitHub https://github.com/ggml-org/llama.cpp/issues/21750?email_source=notifications&email_token=CBTQ2IQT65BDRIGHTZ7WDRT4WKAJNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMRXGA3TAMZXHA32M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-4270703787, or unsubscribe https://github.com/notifications/unsubscribe-auth/CBTQ2IQBCQ7MWDO2MNVFY2D4WKAJNAVCNFSM6AAAAACXUPPNGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DENZQG4YDGNZYG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mollahmasud977-sys avatar Apr 17 '26 19:04 mollahmasud977-sys

when researching gemma4 variable resolution i notice that gemma4 (as far i understand) use 280 and qwen3 use 4096 for image-max-tokens by default tested with b8958, 8000x image, B8, B32 and 3.5-9B works fine with image-max-tokens 2048 and start crashing around 2600

also remembered that i turned off issue detection in adrenaline app, so what if it tell something? after server crash i got pop up that driver was timeout

CatKasha avatar Apr 28 '26 20:04 CatKasha

I met the same problem when I run qwen3.5:4b with llama.cpp on Jetson Thor (aarch64 device) :

when I send the server a message with text + image:

# stub_endpoints.py

def _image_data_url(path: str) -> str:
    """Read `path`, base64-encode, return an OpenAI-style data: URL. Cached per path."""
    cached = _IMAGE_CACHE.get(path)
    if cached is not None:
        return cached
    raw = Path(path).read_bytes()
    mime, _ = mimetypes.guess_type(path)
    if not mime:
        mime = "image/png"
    encoded = base64.b64encode(raw).decode("ascii")
    data_url = f"data:{mime};base64,{encoded}"
    _IMAGE_CACHE[path] = data_url
    return data_url

async def _vlm_locate(visual_desc: str, image_path: str) -> dict[str, Any] | None:
    try:
        data_url = _image_data_url(image_path)
    except OSError as exc:
        log.warning("VLM image unreadable at %s: %s", image_path, exc)
        return None

    url = f"{_llama_base_url()}/v1/chat/completions"
    body: dict[str, Any] = {
        "model": _llama_model(),
        "messages": [
            {"role": "system", "content": _build_vlm_system_prompt()},
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": visual_desc},
                    {"type": "image_url", "image_url": {"url": data_url}},
                ],
            },
        ],
        "temperature": 0.2,
        "max_tokens": 2048,
        "response_format": {"type": "json_object", "schema": _vlm_schema()},
        "chat_template_kwargs": {"enable_thinking": False},
    }

    try:
        async with httpx.AsyncClient(timeout=_llama_timeout_s()) as client:
            resp = await client.post(url, json=body)
            resp.raise_for_status()
            data = resp.json()
    except (httpx.HTTPError, json.JSONDecodeError) as exc:
        log.warning("VLM HTTP/decode error: %s", exc)
        return None

I received : [WARNING] stub_endpoints: VLM HTTP/decode error: Server disconnected without sending a response.

it got : (from docker logs --tail 50 llamacpp-server-cuda)

srv          init: init: chat template, thinking = 0
main: model loaded
main: server is listening on http://0.0.0.0:8080
main: starting the main loop...
srv  update_slots: all slots are idle
srv  params_from_: Chat format: peg-native
slot get_availabl: id  3 | task -1 | selected slot by LRU, t_last = -1
srv  get_availabl: updating prompt cache
srv          load:  - looking for better prompt, base f_keep = -1.000, sim = 0.000
srv        update:  - cache state: 0 prompts, 0.000 MiB (limits: 8192.000 MiB, 32768 tokens, 8589934592 est)
srv  get_availabl: prompt cache update took 0.01 ms
slot launch_slot_: id  3 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> temp-ext -> dist 
slot launch_slot_: id  3 | task 0 | processing task, is_child = 0
slot update_slots: id  3 | task 0 | new prompt, n_ctx_slot = 32768, n_keep = 0, task.n_tokens = 1213
slot update_slots: id  3 | task 0 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id  3 | task 0 | prompt processing progress, n_tokens = 203, batch.n_tokens = 203, progress = 0.167354
/app/ggml/src/ggml-cuda/ggml-cuda.cu:98: CUDA error
CUDA error: an internal operation failed
  current device: 0, in function cublas_handle at /app/ggml/src/ggml-cuda/../ggml-cuda/common.cuh:1451
  cublasCreate_v2(&cublas_handles[device])
libggml-base.so.0(+0x15c24)[0xffff8b435c24]
libggml-base.so.0(ggml_print_backtrace+0x228)[0xffff8b43610c]
libggml-base.so.0(ggml_abort+0x13c)[0xffff8b4362dc]
/app/libggml-cuda.so(_Z15ggml_cuda_errorPKcS0_S0_iS0_+0xcc)[0xffff8191cb7c]
/app/libggml-cuda.so(+0x227fec)[0xffff81927fec]
/app/libggml-cuda.so(+0x2323a4)[0xffff819323a4]
libggml-base.so.0(ggml_backend_sched_graph_compute_async+0x5fc)[0xffff8b452328]
libllama.so.0(_ZN13llama_context13graph_computeEP11ggml_cgraphb+0xa0)[0xffff8b59bb00]
libllama.so.0(_ZN13llama_context14process_ubatchERK12llama_ubatch14llm_graph_typeP22llama_memory_context_iR11ggml_status+0xf0)[0xffff8b59f03c]
libllama.so.0(_ZN13llama_context6decodeERK11llama_batch+0x320)[0xffff8b5a4fe0]
libllama.so.0(llama_decode+0x10)[0xffff8b5a69b4]
/app/llama-server(+0xd7870)[0xaaaaad977870]
/app/llama-server(+0x16ba60)[0xaaaaada0ba60]
/app/llama-server(+0x35028)[0xaaaaad8d5028]
/lib/aarch64-linux-gnu/libc.so.6(+0x284c4)[0xffff8af084c4]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffff8af08598]
/app/llama-server(+0x363f0)[0xaaaaad8d63f0]

To simplify the situation, I tried just to open the 8080 port on web (using web dashboard) and send a message using its multi-modal ability but still got from (docker logs --tail 50 llamacpp-server-cuda):

srv          init: init: chat template, thinking = 0
main: model loaded
main: server is listening on http://0.0.0.0:8080
main: starting the main loop...
srv  update_slots: all slots are idle
srv  log_server_r: done request: GET / 172.17.0.1 200
srv  log_server_r: done request: GET /bundle.css 172.17.0.1 200
srv  log_server_r: done request: GET /bundle.js 172.17.0.1 200
srv  log_server_r: done request: HEAD /cors-proxy 172.17.0.1 404
srv  log_server_r: done request: GET /tools 172.17.0.1 404
srv  log_server_r: done request: GET /tools 172.17.0.1 404
srv  params_from_: Chat format: peg-native
slot get_availabl: id  3 | task -1 | selected slot by LRU, t_last = -1
srv  get_availabl: updating prompt cache
srv          load:  - looking for better prompt, base f_keep = -1.000, sim = 0.000
srv        update:  - cache state: 0 prompts, 0.000 MiB (limits: 8192.000 MiB, 32768 tokens, 8589934592 est)
srv  get_availabl: prompt cache update took 0.01 ms
slot launch_slot_: id  3 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> top-p -> min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id  3 | task 0 | processing task, is_child = 0
slot update_slots: id  3 | task 0 | new prompt, n_ctx_slot = 32768, n_keep = 0, task.n_tokens = 1020
slot update_slots: id  3 | task 0 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id  3 | task 0 | prompt processing progress, n_tokens = 10, batch.n_tokens = 10, progress = 0.009804
srv  log_server_r: done request: POST /v1/chat/completions 172.17.0.1 200
slot update_slots: id  3 | task 0 | n_tokens = 10, memory_seq_rm [10, end)
srv  process_chun: processing image...
encoding image slice...
/app/ggml/src/ggml-cuda/ggml-cuda.cu:98: CUDA error
CUDA error: an internal operation failed
  current device: 0, in function cublas_handle at /app/ggml/src/ggml-cuda/../ggml-cuda/common.cuh:1451
  cublasCreate_v2(&cublas_handles[device])
libggml-base.so.0(+0x15c24)[0xffff952e5c24]
libggml-base.so.0(ggml_print_backtrace+0x228)[0xffff952e610c]
libggml-base.so.0(ggml_abort+0x13c)[0xffff952e62dc]
/app/libggml-cuda.so(_Z15ggml_cuda_errorPKcS0_S0_iS0_+0xcc)[0xffff8b7ccb7c]
/app/libggml-cuda.so(+0x226c6c)[0xffff8b7d6c6c]
/app/libggml-cuda.so(+0x22b868)[0xffff8b7db868]
/app/libggml-cuda.so(+0x2323a4)[0xffff8b7e23a4]
libggml-base.so.0(ggml_backend_sched_graph_compute_async+0x5fc)[0xffff95302328]
libggml-base.so.0(ggml_backend_sched_graph_compute+0x14)[0xffff953027f4]
libmtmd.so.0(_Z23clip_image_batch_encodeP8clip_ctxiPK20clip_image_f32_batchPf+0x908)[0xffff95713ed0]
libmtmd.so.0(mtmd_encode+0x164)[0xffff9569a724]
libmtmd.so.0(mtmd_helper_eval_chunk_single+0xe0)[0xffff9570d930]
/app/llama-server(+0x85374)[0xaaaae4f75374]
/app/llama-server(+0xd7c64)[0xaaaae4fc7c64]
/app/llama-server(+0x16ba60)[0xaaaae505ba60]
/app/llama-server(+0x35028)[0xaaaae4f25028]
/lib/aarch64-linux-gnu/libc.so.6(+0x284c4)[0xffff94db84c4]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffff94db8598]
/app/llama-server(+0x363f0)[0xaaaae4f263f0]

amongtrees avatar May 20 '26 08:05 amongtrees