From bf68c5446ecc2a344e39a7626f436ced72770e85 Mon Sep 17 00:00:00 2001 From: Lumpiasty Date: Sat, 25 Jul 2026 02:32:16 +0200 Subject: [PATCH] server: keep the sleep-wake path active when the VRAM arbiter is enabled The request handler only calls wait_until_no_sleep() (which wakes a server out of its sleeping state) when sleep_idle_seconds >= 0. But the VRAM arbiter's cross-process doorbell can put a server to sleep even when idle-sleep is disabled, so without this a doorbell-slept server would never wake and requests to it would hang until timeout. Do not bypass the wake path when LLAMA_SLEEP_VRAM_ONLY is set, so the arbiter no longer depends on --sleep-idle-seconds being configured. Assisted-by: Claude --- tools/server/server-context.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index deebbfa6a..a6a3389e5 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -4199,8 +4199,12 @@ struct server_res_generator : server_res_spipe { server_response_reader rd; server_res_generator(server_queue & queue_tasks, server_response & queue_results, int sleep_idle_seconds, bool bypass_sleep = false) : rd(queue_tasks, queue_results, HTTP_POLLING_SECONDS) { - // fast path in case sleeping is disabled - bypass_sleep |= sleep_idle_seconds < 0; + // fast path in case sleeping is disabled. Note: the VRAM arbiter (LLAMA_SLEEP_VRAM_ONLY) + // can put the server to sleep via the cross-process doorbell even when idle-sleep is + // disabled (sleep_idle_seconds < 0), so in that case requests must still wake it - otherwise + // a doorbell-slept server would hang, never returning from a request. + static const bool vram_arbiter = getenv("LLAMA_SLEEP_VRAM_ONLY") != nullptr; + bypass_sleep |= (sleep_idle_seconds < 0 && !vram_arbiter); if (!bypass_sleep) { queue_tasks.wait_until_no_sleep(); }