Repository navigation
Studio: keep SSM kernel installs alive and reap the worker on load timeout - #9419
Conversation
…meout Quiet prebuilt causal-conv1d wheel installs were tripping the 300s inactivity deadline and leaving pip/nvcc holding the GPU after Studio already reported the load failed (unslothai#9398).
|
One bug worth fixing first. If someone hits Stop while a load is failing, The AttributeError then replaces the real error, so instead of "load timed out" the user gets that. Two small changes: except Exception as exc:
# cancel_load drops this marker before tearing the worker down,
# so if it's already gone the cancel owns the worker.
cancelled = model_name not in self.loading_models
self.loading_models.discard(model_name)
...
self.active_model_name = None
self.models.clear()
if not cancelled:
try:
self._shutdown_subprocess(timeout = 5)
except Exception as teardown_exc:
logger.warning("Could not shut the failed load's worker down: %s", teardown_exc)
raise
Two minor things: the heartbeat |
cancel_load already owns the worker once it drops the loading marker, and a second _shutdown_subprocess after it nulled _cmd_queue was replacing the real load error with AttributeError. Keep the prebuilt-kernel heartbeat open through the first torch import and join the beat thread so a stray status cannot land after the block.
|
@NilayYadav took your review — thanks. Stop during a failing load no longer sends both threads into Also moved the prebuilt-wheel heartbeat Tests:
Mind another look? |
|
Confirmed the prebuilt-wheel path in studio/backend/utils/ssm_runtime.py still runs without a heartbeat on main and the failed load leaves the worker alive, and the cancel-owns-teardown guard NilayYadav asked for is in. Will get this reviewed. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d17d83e43
ℹ️ 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".
| with _heartbeat( | ||
| status_cb, | ||
| f"Still installing {display_name} (prebuilt kernel)...", | ||
| ): |
There was a problem hiding this comment.
Put a hard deadline around prebuilt installs
If uv or pip becomes permanently stuck rather than merely slow, this heartbeat continues emitting every 60 seconds while install_wheel blocks. Those statuses continually reset _wait_response's only timeout, while the underlying subprocess.run calls in wheel_utils.py have no timeout, so a model load that previously failed after 300 seconds can now remain stuck indefinitely until the user explicitly cancels it. Retain a separate overall installer deadline that heartbeat messages cannot extend.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this unchanged: the heartbeat protects legitimate slow installs, Stop remains available, and source builds already use the same cancellable inactivity semantics. An overall deadline would reintroduce the failure reported in #9398.
|
Codex Review: Didn't find any major issues. Delightful! 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
|
I traced model-load status from the worker through the orchestrator and confirmed the issue and layer are correct: a quiet prebuilt A clean Linux ARM64 CI run installed the real published wheel after a forced 65-second quiet period, observed the heartbeat at 60.1 seconds, and confirmed that concurrent timeout and cancellation cleanup terminated both the worker and its descendant while preserving the timeout (CI run). The hosted runner has no NVIDIA GPU, so this was not a full model load, but it exercised the architecture-specific wheel path. Looks good to merge. |
Problem
Loading a local Qwen3.5 Safetensors model that needs
causal-conv1dcan leave Studio looking ready while chat is broken. On Linux aarch64 the prebuilt wheel install emits one status (Installing causal-conv1d (prebuilt kernel)...) and then goes quiet while pip/uv downloads and unpacks. The parent treats that silence as a dead load:Because
/loadalready committed HTTP 200 after 15s (tunnel padding), the UI can still show the model as loaded. Chat then gets HTTP 400 (No model loaded). Worse, the failed load used to leave the inference subprocess alive, so pip/nvcc kept running and held GPU memory for a long time after Studio had already reported failure. Reported in #9398.Fix
Verification
tests/test_ssm_runtime.py: a quiet prebuilt wheel install emitsStill installing … (prebuilt kernel)heartbeats whileinstall_wheelruns.tests/test_orchestrator_unload_cancel.py: an inactivity timeout waiting forloadedreaps the worker.Fixes #9398