Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

feat(hf): serve concurrent sessions with batched generation

Đang mở
#7,764 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
huggingface, python, pytorch
Lĩnh vực
ai, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
14.6k
Fork
3.9k
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
171

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của livekit/agents

Tất cả issue của livekit/agents

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.