feat(hf): serve concurrent sessions with batched generation
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with livekit/plugins/hf/llm.py and inspect _LoadedModel.generate_lock and the existing generation path. Compare the supported batching options in the installed transformers version with the proposed in-plugin scheduler. Done means concurrent sessions share generation work while LLMStream streaming, cancellation, and tool call behavior stay unchanged; the issue does not identify tests or a specific batching design.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Type
Would make my life easier
Feature Description
livekit-plugins-hf (#7731) loads one copy of the model per process and shares it across sessions. Generation is serialized by a per-model lock, so sessions on the same worker take turns: each caller waits for every reply ahead of it to finish.
Measured on Qwen2.5-0.5B-Instruct, Apple M4 (MPS), temperature=0, 3 sessions sending the same request at the same time:
| time to first token | total | |
|---|---|---|
| one session alone | 99 ms | 481 ms |
| session 1 of 3 | 166 ms | 503 ms |
| session 2 of 3 | 603 ms | 1343 ms |
| session 3 of 3 | 1568 ms | 2448 ms |
Time to first token grows with every session queued ahead. In a voice agent, that is dead air on the line.
Proposal: batch concurrent requests into shared forward passes, so N sessions decode together instead of in sequence. Decoding is memory-bandwidth bound, so a small batch costs little more per step than a single sequence. Options:
transformerscontinuous batching (generate_batch/ the paged-attention cache) where the installed version supports it- a small in-plugin scheduler that pads and steps active requests together
The streaming, cancellation and tool call behaviour of LLMStream stays unchanged.
Workarounds / Alternatives
- One model per job process (the default process executor). This multiplies memory by the number of jobs, so a 1.5B to 7B model fits only a few sessions per GPU.
- Run vLLM or TGI as a separate server and use the
openaiplugin withbase_url. This works, but it adds a separate service, which the local plugin exists to avoid.
Additional Context
- Follow-up to #7731 (the plugin) and part of #5351 (local HF LLM, where KV cache compression is also proposed to raise sessions per GPU).
- The lock is in
livekit/plugins/hf/llm.py:_LoadedModel.generate_lock.
- Lingua principale
- Python
- Stelle
- 14.6k
- Fork
- 3.9k
- Merge medio
- 3g 3h
- PR unite (30g)
- 171
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 livekit/agents
-
Assistant markup is stripped from chat history when expressive mode is offForse già presa @ShivamSharma43 l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsForse di nuovo libera @AbarnaaSree l’ha presa 46 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
livekit/agents#7022 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 22/100
livekit/agents#7843 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
I maintainer di solito rispondono entro 1 giorno
-
StreamPacerWrapper.end_input() sets _input_ended before buffered sentences reach _sentences; last sentence(s) silently never sent to TTSForse già presa @Hugo-DDT l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di livekit/agents
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
WingedGuardian/GENesis-AGI#3375 ·
I maintainer di solito rispondono entro 1 giorno
-
curriculum documentation quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
githubnext/gh-aw-workshop#4601 ·
I maintainer di solito rispondono entro 1 giorno
-
approved Good First Issue scope: docs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno