{"record":{"id":"f1f3c0437e9660d7","repo":"sgl-project/sglang","slug":"got-lora-adapter-that-has-never-been-loaded-lora","errorCode":null,"errorMessage":"Got LoRA adapter that has never been loaded: {lora_path}\\nAll loaded adapters: {self.lora_ref_cache.keys()}.","messagePattern":"Got LoRA adapter that has never been loaded: (.+?)\\\\nAll loaded adapters: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/tokenizer_manager.py","lineNumber":3360,"sourceCode":"        if (\n            get_lora().max_loaded_loras is not None\n            and len(unique_lora_paths) > get_lora().max_loaded_loras\n        ):\n            raise ValueError(\n                f\"Received request with {len(unique_lora_paths)} unique loras requested \"\n                f\"but max loaded loras is {get_lora().max_loaded_loras}\"\n            )\n\n        # Reload all existing LoRA adapters that have been dynamically unloaded\n        unregistered_loras = await self.lora_registry.get_unregistered_loras(\n            unique_lora_paths\n        )\n        for lora_path in unregistered_loras:\n            if lora_path is None:\n                continue\n\n            if lora_path not in self.lora_ref_cache:\n                raise ValueError(\n                    f\"Got LoRA adapter that has never been loaded: {lora_path}\\n\"\n                    f\"All loaded adapters: {self.lora_ref_cache.keys()}.\"\n                )\n\n            logger.info(f\"Reloading evicted adapter: {lora_path}\")\n            new_lora_ref = self.lora_ref_cache[lora_path]\n            load_result = await self.load_lora_adapter(\n                LoadLoRAAdapterReqInput(\n                    lora_name=new_lora_ref.lora_name,\n                    lora_path=new_lora_ref.lora_path,\n                    pinned=new_lora_ref.pinned,\n                )\n            )\n            if (\n                not load_result.success\n                and \"already loaded\" not in load_result.error_message\n            ):\n                raise ValueError(","sourceCodeStart":3342,"sourceCodeEnd":3378,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/tokenizer_manager.py#L3342-L3378","documentation":"During reload of dynamically-unloaded (evicted) adapters, a path was found in the unregistered set that has no entry in the tokenizer-side lora_ref_cache, meaning it was never registered/loaded on this node. This indicates registry/cache desynchronization, common after a worker restart or state reset.","triggerScenarios":"A request references a previously loaded but evicted adapter; get_unregistered_loras returns it, yet lora_ref_cache has no key for that path (cache cleared, cross-process mismatch, or adapter memory dropped by a different mechanism).","commonSituations":"Scheduler restart or failover losing tokenizer-side ref-cache state; adapters unloaded via internal eviction while cache invalidation raced; version upgrades changing eviction bookkeeping.","solutions":["Restart the service so registry and ref-cache are rebuilt from --lora-paths","Explicitly reload the adapter via /load_lora_adapter before retrying the request","Report/upstream if reproducible — the caches should not desync; include adapter paths and logs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"loaded = set(get_loaded_lora_adapters())  # via /get_server_info or registry\nmissing = [p for p in requested_paths if p and p not in loaded]\nif missing:\n    await load_adapters(missing)  # /load_lora_adapter","typeGuard":null,"tryCatchPattern":"try:\n    out = await engine.generate(prompt, lora_path=p)\nexcept ValueError as e:\n    if \"never been loaded\" in str(e):\n        await load_lora_adapter(p)\n        out = await engine.generate(prompt, lora_path=p)  # one retry\n    else:\n        raise","preventionTips":["Preload adapters explicitly instead of relying on implicit reload after eviction","Watch logs for 'Reloading evicted adapter' to detect thrash near the limit","Restart the server after worker failover before resending adapter requests"],"tags":["lora","eviction","state-desync","cache"],"backgroundTag":"stale-cache-inconsistency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}