flm serve: /v1/completions, /api/generate and /api/chat keep decoding after the client disconnects
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- api, backend, performance
Direzione di ricerca
Start in src/server/rest_handler.cpp at the /v1/completions, /api/generate, and /api/chat handlers, comparing them with handle_openai_chat_completion and the cancellation setup in src/server/server.cpp. Read generate_with_prompt in src/include/AutoModel/automodel.hpp, then use a client-disconnect probe during streaming and non-streaming requests. Done means all listed routes stop decoding promptly and release the NPU lock after cancellation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Everything below comes from reading the source on main at 39ff855. None of it has been measured.
What looks wrong
The server creates a CancellationToken for every request. The token is cancelled when the client socket closes (server.cpp:357-388) or when /api/cancel is called. /v1/chat/completions uses it: it calls cancellation_token->reset() and passes [&] { return cancellation_token->cancelled(); } to both insert() and generate() (rest_handler.cpp:1194-1236, :1257-1288).
The other generation routes accept the token and never read it:
/v1/completions:insert()andgenerate()at:1445,:1459,:1476,:1490/api/generate::677,:691,:710,:724/api/chat: streaming at:793/:807. Non-streaming usesgenerate_with_prompt()(:835), which has no cancellation parameter at all (automodel.hpp:434).
So if a client drops mid-request on one of these routes, the server should keep decoding to max_tokens / num_predict (default 4096). For /api/generate and /api/chat, that also holds the NPU lock and blocks the queue behind it. /v1/completions isn't queued at all (see #759). /api/cancel has no effect on these routes for the same reason.
Expected
Cancelling on disconnect behaves the same on every generation route as it does on /v1/chat/completions.
Suggested fix
In each of these handlers, call cancellation_token->reset() and pass the same [&] { return cancellation_token->cancelled(); } predicate to insert() and generate(), as handle_openai_chat_completion does. Non-streaming /api/chat would need either a predicate on generate_with_prompt() or a switch to insert() + generate(). The second option changes output for Qwen3.5, Qwen3.6-MoE and GPT-OSS, whose generate_with_prompt() differs from that pair.
A probe that closes the connection mid-stream should confirm it: eval_count in the log stops short, and NPU Lock Released! follows promptly. We haven't run it yet.
Environment
Found by reading the source; checked against main at 39ff855 and v1.0.6.
Related, but a different resource: #680, where client aborts leak connection slots.
- Lingua principale
- C++
- Stelle
- 2.1k
- Fork
- 184
- Merge medio
- 12h 22m
- PR unite (30g)
- 239
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ROCm/FastFlowLM
-
Update Gemma tokenizer.json after Google's recent fixForse già presa @four1er l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ROCm/FastFlowLM#1057 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ROCm/FastFlowLM#757 ·
I maintainer di solito rispondono entro 1 giorno
-
No valid checkpoint to restore + Max length reached on multi-turn tool calls (Qwen3.6-MoE, NPU)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ROCm/FastFlowLM#744 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Truncated tool call is emitted as a complete one (unterminated heredoc reaches the client)Forse già presa @Javinator9889 l’ha presa 72 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ROCm/FastFlowLM#741 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Download timeoutForse già presa @stdevPavelmc l’ha presa 200 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ROCm/FastFlowLM#520 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ROCm/FastFlowLM
Issue simili
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
difficulty:easy func:gui prio:normal type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NatronGitHub/Natron#2118 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
bug difficulty:easy prio:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NatronGitHub/openfx-io#523 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
ArduPilot/ardupilot_gazebo#195 ·