unslothai/unsloth · error · RuntimeError

No active model

Error message

No active model

What it means

Guard in generate_audio: the worker may be alive but active_model_name is empty — no model is published as active. This happens after an unload, a failed load, or a teardown that cleared model state (several paths set active_model_name = None).

Source

Thrown at studio/backend/core/inference/orchestrator.py:2113

        self,
        text: str,
        temperature: float = 0.6,
        top_p: float = 0.95,
        top_k: int = 50,
        min_p: float = 0.0,
        max_new_tokens: int = 2048,
        repetition_penalty: float = 1.0,
        use_adapter: Optional[Union[bool, str]] = None,
        cancel_event = None,
    ) -> Tuple[bytes, int]:
        """Generate TTS audio. Returns (wav_bytes, sample_rate).

        Blocking — sends command and waits for the full audio response.
        """
        if not self._ensure_subprocess_alive():
            raise RuntimeError("Inference subprocess is not running")
        if not self.active_model_name:
            raise RuntimeError("No active model")
        expected_model = self.active_model_name

        # Serialize under _gen_lock and reserve dispatcher admission before waiting for
        # compare work to drain. A bare idle wait is racy: a compare request can register
        # between the wait and this command, leaving TTS queued without safe ownership of
        # the worker's single shared cancel event.
        with self._gen_lock:
            with self._dispatcher_lifecycle_lock:
                self._exclusive_tts_pending = True
            try:
                dispatcher_idle = self._wait_dispatcher_idle(cancel_event = cancel_event)
                if cancel_event is not None and cancel_event.is_set():
                    raise AudioGenerationCancelledError("Audio generation cancelled")
                if not dispatcher_idle:
                    raise RuntimeError(
                        "Cannot start audio generation while compare requests are active"
                    )

View on GitHub (pinned to 203007d190)

Solutions

  1. Load a model and wait for the loaded response before calling generate_audio.
  2. Refresh frontend model state after unload/cancel so audio requests are not sent.
  3. Check orchestrator.active_model_name before issuing audio work.

Example fix

// before
wav, sr = orchestrator.generate_audio(text)
// after
if not orchestrator.active_model_name:
    raise RuntimeError("load a model before requesting audio")
wav, sr = orchestrator.generate_audio(text)
Defensive patterns

Strategy: validation

Validate before calling

if not orchestrator.active_model_name:
    raise ValueError("load a model before requesting audio")

Type guard

def has_active_model(orch) -> bool:
    return orch.active_model_name is not None

Prevention

When it happens

Trigger: Calling TTS generation right after /unload, after a load failure, or after a cancel path that cleared active_model_name and models while the worker object still exists.

Common situations: Race between UI unloading a model and a queued TTS request; retrying audio after a cancelled load; stale frontend state showing a model as loaded when the backend already dropped it.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/bc024ae7389cb253. Report an issue: GitHub.