You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A worker now hosts one LLMEngine (weights loaded once) and serves multiple
isolated sessions keyed by session_id, each with its own KV/recurrent state, up
to the engine's serving capacity -- so one ~18GB model load backs many
independent conversations instead of one. Execution stays synchronous (one
in-flight request; the control plane serializes): this is isolation, not
concurrent streaming.
The shared worker loop (worker_loop.h) owns the sessions. Named sessions are
created on first use (or an `open` op) and capped at capacity-1; one slot is
reserved for a scratch session that serves anonymous, session-less requests.
Over-capacity or single-session backends return structured errors
(capacity_exhausted / unsupported_session); there is no eviction/TTL in the MVP,
so capacity_exhausted stands when named sessions exceed worker capacity. Both
workers (text_llm_worker, qwen3_5_moe_worker) now pass their LLMEngine to the
loop.
The control plane (over the SessionRuntime boundary introduced earlier) routes a
request to a session via the session_id body field or, as header aliases,
X-ExecuTorch-Session-ID / session_id / x-session-affinity (body wins, then that
header order). The aliases let a client that already emits a stable
per-conversation affinity id (e.g. pi's sendSessionAffinityHeaders) route with no
client-specific server code. The session is admitted up front (so a capacity
refusal is HTTP 429/400 before any stream bytes), and DELETE /v1/sessions/{id}
frees one.
Review order: worker_loop.h (session ownership + protocol), then the two
workers; then the control plane (protocol.py, errors.py, serving_chat.py,
server.py, serve.py); then tests.
Part of #20001
ghstack-source-id: fca5361
ghstack-comment-id: 4661783584
Pull-Request: #20159
0 commit comments