{"record":{"id":"405a17f18191eaab","repo":"mudler/LocalAI","slug":"model-not-loaded","errorCode":null,"errorMessage":"Model not loaded","messagePattern":"Model not loaded","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"backend/python/liquid-audio/backend.py","lineNumber":383,"sourceCode":"\n        See `backend.proto` AudioToAudioStream for the wire protocol. Audio\n        is decoded once per turn here; chunked detokenization for sub-second\n        TTFB is left to a future iteration once the LFM2AudioDetokenizer\n        gains a streaming entry point.\n        \"\"\"\n        try:\n            yield from self._audio_to_audio_stream(request_iterator, context)\n        except Exception as exc:\n            print(f\"AudioToAudioStream failed: {exc}\", file=sys.stderr)\n            print(traceback.format_exc(), file=sys.stderr)\n            yield backend_pb2.AudioToAudioResponse(\n                event=\"error\",\n                meta=json.dumps({\"message\": str(exc)}).encode(\"utf-8\"),\n            )\n\n    def _audio_to_audio_stream(self, request_iterator, context):\n        if self.model is None or self.processor is None:\n            raise RuntimeError(\"Model not loaded\")\n\n        import torch\n        import torchaudio\n        from liquid_audio import ChatState\n\n        cfg = None\n        chat = None\n        input_sample_rate = 16000\n        output_sample_rate = 24000\n        sequence = 0\n\n        def _new_event(event, **kwargs):\n            nonlocal sequence\n            sequence += 1\n            kwargs.setdefault(\"sequence\", sequence)\n            return backend_pb2.AudioToAudioResponse(event=event, **kwargs)\n\n        def _ensure_chat():","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/liquid-audio/backend.py#L365-L401","documentation":"RuntimeError from liquid-audio backend's AudioToAudioStream handler: _audio_to_audio_stream() requires self.model and self.processor, which are only populated by a successful LoadModel gRPC call. Streaming audio-to-audio without a prior model load fails immediately; the outer handler catches it and yields an error event with the message in meta JSON.","triggerScenarios":"Calling the AudioToAudioStream gRPC method on a fresh backend process before LoadModel; calling after a LoadModel that failed midway leaving model None; calling after the model was unloaded/released.","commonSituations":"Client code starts streaming immediately after backend process start, assuming the model auto-loads from a startup flag; a failed load (OOM, wrong model id) leaves the backend half-initialized and the next stream call hits this.","solutions":["Send a LoadModel request (with model id) and wait for its success response before calling AudioToAudioStream","Check the LoadModel response for errors — if it failed, fix the load error (model id, memory, dependencies) first","If this happens mid-session, the model may have been unloaded; reload it before streaming again"],"exampleFix":"# before\nresponses = stub.AudioToAudioStream(iter(chunks))  # no LoadModel yet\n\n# after\nstub.LoadModel(backend_pb2.ModelOptions(model=\"LiquidAI/LFM2.5-Audio-1.5B\"))\nresponses = stub.AudioToAudioStream(iter(chunks))","handlingStrategy":"validation","validationCode":"# Before streaming, confirm the model is resident via the Health/loaded-model RPC,\n# or track load state client-side:\nloaded = False\nresp = stub.LoadModel(backend_pb2.ModelOptions(model=MODEL_ID))\nloaded = resp.success  # or not resp.error, per your proto\nif not loaded:\n    raise RuntimeError(\"LoadModel failed; not starting AudioToAudioStream\")","typeGuard":null,"tryCatchPattern":"try:\n    for event in stub.AudioToAudioStream(chunk_iter()):\n        ...\nexcept grpc.RpcError as e:\n    if \"Model not loaded\" in str(e.details()):\n        reload_model_and_retry()  # LoadModel then retry once\n    else:\n        raise","preventionTips":["Always pair backend process start with an explicit LoadModel and check its response","Watch for backend restarts (channel reconnection) and re-load the model before streaming"],"tags":["python","grpc","liquid-audio","model-loading","streaming"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}