Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

feat(hf): serve concurrent sessions with batched generation

Aperta
#7,764 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
huggingface, python, pytorch
Ambito
ai, backend

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:

  • transformers continuous 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 openai plugin with base_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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di livekit/agents

Tutte le issue di livekit/agents

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.