feat(stream): time-slice retained LingBot sessions - #21
Merged
Conversation
Load one shared stream service per in-process model worker while retaining multiple independent LiveKit room and pipeline sessions. Add retained-session admission capacity, control-idle execution leases, chunk-boundary handoff, aggregate worker health, and controller heartbeats. Clarify service-instance, queue, lifecycle, GPU placement, and observability semantics across the English and Chinese documentation. Add focused lease, worker, capacity, CLI, runtime, and action-loop coverage, and isolate localhost server tests from process-level proxies. Verified with full Ruff and import checks, 857 CI-selected unit tests, 62 server tests, strict bilingual MkDocs build, and git diff checks.
Consolidate the English and Chinese service, stream-server, and scheduler guides around explicit ownership boundaries and Mermaid architecture diagrams. Clarify shared service instances, room roles and viewer fan-out, retained admission, LingBot execution leases, lifecycle limits, GPU-map behavior, and observability semantics. Remove duplicated setup and topology guidance from the general service and LingBot example documentation. Verified with strict bilingual MkDocs build and git diff checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Load one shared stream service per in-process model worker while retaining multiple independent LiveKit room and pipeline sessions.
This change adds retained-session admission capacity and a LingBot execution lease that serializes model work across sessions at chunk boundaries. It also aligns worker health aggregation, controller activity handling, CLI configuration, examples, and documentation with the multi-session lifecycle.
The default retained-session capacity remains
1, preserving existing behavior unless multi-session operation is explicitly enabled.Motivation
Previously, one LiveKit worker effectively handled one room session at a time. Supporting multiple users by loading a separate model instance per session would duplicate model weights and significantly increase GPU memory consumption.
This change allows multiple user sessions to share one loaded model service while preserving independent room, control, cache, noise, VAE, and pipeline-session state. When multiple sessions request execution, the LingBot service grants one execution lease and hands it off at a chunk boundary after the active controller becomes idle.
This provides bounded time-division multiplexing without introducing continuous batching, cross-session state sharing, or additional model replicas.
Type of Change
Changes Made
max_sessions_per_workerandcontrol_idle_timeout.Testing
Test commands:
Results:
Checklist
ruff)[TYPE] Brief descriptionRelated Issues
None.
Additional Notes
max_sessions_per_workerdefaults to1, so existing deployments retain their previous behavior.BidirectionalService; server-push capacity greater than one is rejected.stream-serveprocesses and external routing.control_idle_timeoutonly controls execution-lease handoff when another session is waiting. It does not close the idle session, release its admission slot, or free its per-session cache.GPU Architecture Support
Not applicable. This PR does not add or modify CUDA or Triton kernels.
Performance Impact
The change avoids loading one model service instance per user session. Multiple retained sessions share model weights while keeping session-specific runtime state isolated.
Only one LingBot session chunk executes at a time, so the change does not increase model compute concurrency or claim a throughput improvement. Lease handoff introduces only control-path synchronization at chunk boundaries.
Parked sessions retain per-session cache and pipeline state, so GPU memory usage grows with retained-session count. Two-session operation was manually validated on four H100 GPUs; no new formal benchmark is included.