{"record":{"id":"38cca919f85e2f6f","repo":"unslothai/unsloth","slug":"inference-subprocess-is-not-running","errorCode":null,"errorMessage":"Inference subprocess is not running","messagePattern":"Inference subprocess is not running","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/orchestrator.py","lineNumber":2111,"sourceCode":"\n    def generate_audio_response(\n        self,\n        text: str,\n        temperature: float = 0.6,\n        top_p: float = 0.95,\n        top_k: int = 50,\n        min_p: float = 0.0,\n        max_new_tokens: int = 2048,\n        repetition_penalty: float = 1.0,\n        use_adapter: Optional[Union[bool, str]] = None,\n        cancel_event = None,\n    ) -> Tuple[bytes, int]:\n        \"\"\"Generate TTS audio. Returns (wav_bytes, sample_rate).\n\n        Blocking — sends command and waits for the full audio response.\n        \"\"\"\n        if not self._ensure_subprocess_alive():\n            raise RuntimeError(\"Inference subprocess is not running\")\n        if not self.active_model_name:\n            raise RuntimeError(\"No active model\")\n        expected_model = self.active_model_name\n\n        # Serialize under _gen_lock and reserve dispatcher admission before waiting for\n        # compare work to drain. A bare idle wait is racy: a compare request can register\n        # between the wait and this command, leaving TTS queued without safe ownership of\n        # the worker's single shared cancel event.\n        with self._gen_lock:\n            with self._dispatcher_lifecycle_lock:\n                self._exclusive_tts_pending = True\n            try:\n                dispatcher_idle = self._wait_dispatcher_idle(cancel_event = cancel_event)\n                if cancel_event is not None and cancel_event.is_set():\n                    raise AudioGenerationCancelledError(\"Audio generation cancelled\")\n                if not dispatcher_idle:\n                    raise RuntimeError(\n                        \"Cannot start audio generation while compare requests are active\"","sourceCodeStart":2093,"sourceCodeEnd":2129,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/orchestrator.py#L2093-L2129","documentation":"Guard at the top of the TTS generate_audio path: _ensure_subprocess_alive() returned False, meaning there is no running inference worker (never started, crashed, or shut down). No audio request can even be enqueued in this state.","triggerScenarios":"Calling generate_audio (TTS) before any model was loaded, after the subprocess died from an OOM/crash, or after a shutdown triggered by a prior cancel/stall teardown.","commonSituations":"Frontend fires a TTS request on app startup before load completes; worker crashed earlier in the session and the user retries audio; load was cancelled leaving no worker.","solutions":["Load a TTS-capable model first and wait for it to finish before requesting audio.","Check backend logs for why the subprocess is gone (crash, stall teardown, cancel drain).","Retry after a successful model load re-spawns the worker.","If the worker keeps dying, fix the underlying crash (see the worker error in logs)."],"exampleFix":"// before\nwav, sr = orchestrator.generate_audio(text)\n// after\nif not orchestrator.is_worker_alive():\n    orchestrator.load_model(tts_model)\nwav, sr = orchestrator.generate_audio(text)","handlingStrategy":"validation","validationCode":"if not orchestrator.is_worker_alive():\n    orchestrator.load_model(tts_model)  # spawn worker before audio","typeGuard":"def can_generate_audio(orch) -> bool:\n    return orch.is_worker_alive() and bool(orch.active_model_name)","tryCatchPattern":null,"preventionTips":["Gate audio requests on worker liveness and an active model.","After any teardown (cancel/stall), reload before the next audio request.","Handle worker-crash errors upstream so the UI knows audio is unavailable."],"tags":["inference","tts","subprocess","precondition"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}