flm serve: /v1/completions, /api/generate and /api/chat keep decoding after the client disconnects
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 68/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- cpp
- Domaine
- api, backend, performance
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- C++
- Étoiles
- 2.1k
- Forks
- 184
- Merge moyen
- 12 h 22 min
- PR mergées (30 j)
- 239
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ROCm/FastFlowLM
-
Update Gemma tokenizer.json after Google's recent fixPeut-être pris @four1er l’a pris il y a 6 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ROCm/FastFlowLM#1057 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ROCm/FastFlowLM#757 ·
Les mainteneurs répondent en général sous 1 jour
-
No valid checkpoint to restore + Max length reached on multi-turn tool calls (Qwen3.6-MoE, NPU)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
ROCm/FastFlowLM#744 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Truncated tool call is emitted as a complete one (unterminated heredoc reaches the client)Peut-être pris @Javinator9889 l’a pris il y a 72 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ROCm/FastFlowLM#741 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Download timeoutPeut-être pris @stdevPavelmc l’a pris il y a 200 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
ROCm/FastFlowLM#520 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de ROCm/FastFlowLM
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
riscv-software-src/riscv-isa-sim#2640 ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
difficulty:easy func:gui prio:normal type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
NatronGitHub/Natron#2118 ·
Les mainteneurs répondent en général sous 1 jour
-
Bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
-
mechanics UI
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
endless-sky/endless-sky#12949 ·
Les mainteneurs répondent en général sous 1 jour