Repository navigation
Studio: keep the chat model loaded when an API request loads a speech model - #14369
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e9b16391b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| async with model_load_gate(), inference_lifecycle_gate(): | ||
| # A load kept beside the primary goes through load_model_gated, which takes the | ||
| # load gate itself and leaves the primary serving while it loads. | ||
| beside = await asyncio.to_thread(_switch_loads_beside, require_speech) |
There was a problem hiding this comment.
Decide alongside placement under the load gate
When a concurrent manual /load changes the primary model after this check but before load_model_gated acquires model_load_gate, beside describes the old primary. For example, a speech request can observe a text primary, then a manual load can replace it with another speech model; the request still submits alongside=True, so _select_load_slot keeps two speech models instead of replacing the now-current one and may even return an Always-mode fit refusal that replacement would avoid. Re-evaluate the primary's kind while holding the load gate that selects the slot.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: it needs a manual /load to land in the window between the check and the gate, and the result is a second speech model kept under Keep multiple models loaded (When they fit unloads idle ones if short), not a lost or wrong load.
… cancel, refuses cached copies and waits for running chats [skip ci]
…t cancel into the load attempt, refuse an unreserved kept slot, recheck the sidecar after the drain [skip ci]
…s the active model [skip ci]
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #14320
Summary
With Keep multiple models loaded set to When they fit or Always, a speech model loaded from the Audio page already stays beside the chat model (#14191). An API request does not. When
/v1/audio/speechnames a speech model while a chat model is loaded:Loading this model would unload the chat model ..., and Keep multiple models loaded is set to Always.The same happens in the other order, a chat request naming the chat model while a speech model is loaded.
The automatic load behind API requests always loaded into the primary seat. It never asked for a kept slot the way the Audio page and the chat auto-load do with
alongside.Changes
load_model_gatedwithalongside=True. That is the same pathPOST /loaduses: the kept slot, the fit checks, unloading idle models first under When they fit, and the refusal under Always when the new model does not fit. The request is then served from the new slot.load_model_gatedand_run_tracked_load_model_impltake an optionalimpl_kwargs, so the speech codec staging the switch prepares still reaches the load.Testing
Kaggle T4x2, both Studios installed with
install.sh --localfrom main4b8447f63a(base on GPU0, base plus this change on GPU1). Chat modelunsloth/Qwen3.5-2B-GGUFQ4_K_M, speech modelaudio-cpp/audio.cpp-gguf/Kokoro-82M-GGUFthrough the API. "Serving" is what/api/inference/statusreports./v1/audio/speech/v1/chat/completions, then speech again/v1/audio/speech/v1/audio/speechalongside: trueThe clips are the same size on both sides (106844, 75644 and 72044 bytes).
Unit tests in
tests/test_openai_auto_switch.py:The three beside cases fail on main.
test_openai_auto_switch.py,test_multi_model_always.pyandtest_multi_model_serving.pyall pass (965 passed). The 65 backend test files that touch the changed functions pass too. The 5 failures under-n 24also pass serially on both main and this branch, so they are parallel-run flakes.Before / after
Colab T4, both Studios built with
install.sh --local(main4b8447f63and this PR atc74df642c), Keep multiple models loaded set to When they fit. One/v1/chat/completionsrequest namingunsloth/Qwen3.5-2B-GGUF, then one/v1/audio/speechrequest namingaudio-cpp/audio.cpp-gguf/Kokoro-82M-GGUF, then the loaded-models card on the chat page.The same run on the final head repeats the table above: under When they fit and Always both models stay served in either order, Off still replaces, and the Kokoro clips are the same size on both sides (121244 bytes).