flm serve: /v1/completions and other routes run outside the NPU queue and race with model swaps
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- api, backend, performance
Línea de trabajo
Start in src/server/server.cpp at requires_npu_access(), then trace the route dispatch in src/src/main.cpp and the handlers in src/server/rest_handler.cpp, especially completion, embeddings, model loading, and /api/ps. Confirm which engine accesses and model-tag reads can overlap, then define done as serialized NPU work and a synchronized /api/ps view without changing unrelated routes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Everything below comes from reading the source on main at 39ff855. None of it has been measured.
What looks wrong
requires_npu_access() decides which requests go through the single NPU queue (server.cpp:160-170). It lists /api/generate, /api/chat, /v1/chat/completions, /v1/audio/transcriptions and /v1/embeddings. Every other route runs directly on whichever of the 10 I/O threads accepted it (main.cpp:624), concurrently with whatever holds the NPU. Three of those routes touch state that the queued routes change:
-
POST /v1/completionsis missing from the list, but it does inference.handle_openai_completioncallsensure_model_loaded(),insert()andgenerate()on the sharedauto_chat_engine(rest_handler.cpp:1423-1490). A/v1/completionsrequest that arrives while a/v1/chat/completionsrequest is decoding would therefore run on the same engine and the same NPU at the same time. If it names a different model, it would reset the engine that the other request is using (:385-388). -
POST /api/embeddingsis also missing, while its twin/v1/embeddingsis listed. Both call the samehandle_embeddings, which runs the embedding model on the NPU. -
GET /api/psreadscurrent_model_tag(:1017-1022). Meanwhile,ensure_model_loadedassigns thatstd::stringon a queued request's thread (:411,:418). A concurrent read of astd::stringduring assignment is a data race, and undefined behaviour in C++.We have measured one consequence on our patched build. The tag stays at the
model-fakersentinel until a first load finishes. Polling/api/pswhile that load ran hit the sentinel lookup (a separate bug: undefined behaviour inrectify_model_tag) on 19 of 23 polls.
Expected
Anything that uses or swaps auto_chat_engine or the embedding engine goes through the NPU queue. For a read-only route like /api/ps, a snapshot of (engine loaded, tag) published under a mutex, or atomically, would be enough.
Suggested fix
- Add
/v1/completionsand/api/embeddingstorequires_npu_access(). - Give
/api/psa synchronised view of the loaded tag.
We have not written a patch for this yet. We found it while fixing /api/ps downstream. That fix (https://github.com/noamsto/nix-amd-ai/blob/46d7a73c1044435cec0ff08410e1a3bc87cbc544/pkgs/fastflowlm/patches/ps-loaded-models.patch) avoids the sentinel lookup, but it does not add synchronisation.
The heap-corruption reports in #608 involve concurrent requests. We haven't connected them to this, so this is only a pointer.
Environment
Found by reading the source; checked against main at 39ff855 and v1.0.6.
- Lenguaje dominante
- C++
- Estrellas
- 2.1k
- Forks
- 184
- Merge medio
- 12 h 22 min
- PR fusionados (30 d)
- 239
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ROCm/FastFlowLM
-
Update Gemma tokenizer.json after Google's recent fixPosiblemente ocupada @four1er la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ROCm/FastFlowLM#1057 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ROCm/FastFlowLM#757 ·
Los mantenedores suelen responder en 1 día
-
No valid checkpoint to restore + Max length reached on multi-turn tool calls (Qwen3.6-MoE, NPU)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ROCm/FastFlowLM#744 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Truncated tool call is emitted as a complete one (unterminated heredoc reaches the client)Posiblemente ocupada @Javinator9889 la tomó hace 72 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ROCm/FastFlowLM#741 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Download timeoutPosiblemente ocupada @stdevPavelmc la tomó hace 200 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
ROCm/FastFlowLM#520 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de ROCm/FastFlowLM
Issues similares
-
bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
difficulty:easy func:gui prio:normal type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NatronGitHub/Natron#2118 ·
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
-
bug difficulty:easy prio:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NatronGitHub/openfx-io#523 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
ArduPilot/ardupilot_gazebo#195 ·