llama-swap: [Bug] Terminating llama-swap doesn't always kill child process
An example I can reliably reproduce is when llama-server has a CUDA out of memory error, it doesn’t terminate and stays in a hanged state - it responds to API but no inference is done. Terminating llama-swap via CTRL-C leaves the childllama-server process running.
This is the config yaml:
"Mistral-Small-3.1-24B":
cmd:
/models/llama.cpp/llama-server -m /models/Mistral-Small-3.1-24B-Instruct-2503-Q8_0.gguf
-md /models/Mistral-Small-3.1-DRAFT-0.5B.Q8_0.gguf
-fa -sm row --no-mmap
-ngl 99 -ngld 99 --port 9009 -c 65536
--draft-max 16 --draft-min 5 --draft-p-min 0.5
--device CUDA2,CUDA1 --device-draft CUDA1 --tensor-split 0,1,1
--slots --metrics --numa distribute -t 40 --no-warmup
proxy: http://127.0.0.1:9009
aliases:
- mistral-3.1
checkEndpoint: /health
ttl: 300
And here’s the output with log level debug in config:
main: server is listening on http://127.0.0.1:9009 - starting the main loop
srv update_slots: all slots are idle
srv log_server_r: request: GET /health 127.0.0.1 200
[INFO] Health check passed on http://127.0.0.1:9009/health
[DEBUG] State transition from starting to ready
srv params_from_: Chat format: Content-only
slot launch_slot_: id 0 | task 0 | processing task
slot update_slots: id 0 | task 0 | new prompt, n_ctx_slot = 65536, n_keep = 0, n_prompt_tokens = 110
slot update_slots: id 0 | task 0 | kv cache rm [0, end)
slot update_slots: id 0 | task 0 | prompt processing progress, n_past = 110, n_tokens = 110, progress = 1.000000
slot update_slots: id 0 | task 0 | prompt done, n_past = 110, n_tokens = 110
/home/ali/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu:75: CUDA error
CUDA error: out of memory
current device: 1, in function alloc at /home/ali/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu:450
cuMemCreate(&handle, reserve_size, &prop, 0)
[INFO] Request 192.168.1.207 "GET /v1/models HTTP/1.1" 200 530 "Python/3.12 aiohttp/3.11.11" 144.624µs
[INFO] Request 192.168.1.207 "GET /v1/models HTTP/1.1" 200 530 "Python/3.12 aiohttp/3.11.11" 57.76µs
[DEBUG] No-swap, using existing process for model [Mistral-Small-3.1-24B]
srv params_from_: Chat format: Content-only
^CShutting down llama-swap
[INFO] Request 192.168.1.207 "POST /v1/chat/completions HTTP/1.1" 502 15 "Python/3.12 aiohttp/3.11.11" 31.898049308s
[INFO] Process [Mistral-Small-3.1-24B] timed out waiting to stop, sending KILL signal
[DEBUG] Process [Mistral-Small-3.1-24B] stopCommand took 5.004076432s
(.venv) ali@smolboi:/models$ ps aux | grep llama
ali 48562 0.0 0.1 90291408 494724 pts/3 S 22:57 0:00 /models/llama.cpp/llama-server -m /models/Mistral-Small-3.1-24B-Instruct-2503-Q8_0.gguf -md /models/Mistral-Small-3.1-DRAFT-0.5B.Q8_0.gguf -fa -sm row --no-mmap -ngl 99 -ngld 99 --port 9009 -c 65536 --draft-max 16 --draft-min 5 --draft-p-min 0.5 --device CUDA2,CUDA1 --device-draft CUDA1 --tensor-split 0,1,1 --slots --metrics --numa distribute -t 40 --no-warmup
ali 48569 0.0 0.0 6544 1536 pts/3 S+ 22:59 0:00 grep --color=auto llama
Just filed a bug in llama.cpp about this.
I don’t think llama-swap should handle the CUDA error, though it would be nice if it did, as it would make llama-swap quite more reliable. OTOH, the only way I see this being handled is redirecting the child process’ stdout to llama-swap and searching the messages for “CUDA error”. I wouldn’t like to do this if it was me.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 23 (13 by maintainers)
This issue also went off the rails. Sorry @FullstackSensei I don’t think we resolved your initial issue either. 🤦
Also, #102 is only part way to a full “monitor upstream for exits”. That is a level of complexity I’m not ready to tackle yet. 😃