{"record":{"id":"5cb3bed05d72e60e","repo":"sgl-project/sglang","slug":"failed-to-load-lora-adapter-lora-ref-lora-name-b","errorCode":null,"errorMessage":"Failed to load LoRA adapter {lora_ref.lora_name} because it is already loaded","messagePattern":"Failed to load LoRA adapter (.+?) because it is already loaded","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/lora/lora_manager.py","lineNumber":292,"sourceCode":"\n    def validate_new_adapter(self, lora_config: LoRAConfig, lora_ref: LoRARef):\n        \"\"\"\n        Validate if an adapter can be loaded into the current LoRA memory pool and generate error if it is incompatible.\n        \"\"\"\n        if lora_config.lora_added_tokens_size > 0:\n            raise ValueError(\n                f\"Failed to load {lora_ref.lora_name} because LoRA serving currently doesn't support adapters that add tokens to the vocabulary\"\n            )\n\n        if lora_config.use_dora:\n            raise ValueError(\n                f\"Failed to load {lora_ref.lora_name} because LoRA serving currently doesn't support DoRA adapters\"\n            )\n\n        # Check if this LoRA adapter is already loaded\n        for existing_lora_ref in self.lora_refs.values():\n            if lora_ref.lora_name == existing_lora_ref.lora_name:\n                raise ValueError(\n                    f\"Failed to load LoRA adapter {lora_ref.lora_name} because it is already loaded\"\n                )\n\n            if lora_ref.lora_path == existing_lora_ref.lora_path:\n                logger.warning(\n                    f\"{lora_ref.lora_path} is already loaded with name: {existing_lora_ref.lora_name}, \"\n                    f\"but another copy is being loaded with name: {lora_ref.lora_name}\"\n                )\n\n        # Check if the LoRA adapter shape is compatible with the current LoRA memory pool configuration.\n        memory_pool = getattr(self, \"memory_pool\", None)\n        incompatible = memory_pool and not memory_pool.can_support(lora_config)\n        if incompatible:\n            raise ValueError(\n                f\"LoRA adapter {lora_ref.lora_name} with rank {lora_config.r} is incompatible with the current \"\n                \"LoRA memory pool configuration. Please ensure that the LoRA adapter's rank is within the configured \"\n                \"`--max-lora-rank` and that the target modules are included in `--lora-target-modules`.\"\n            )","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/lora/lora_manager.py#L274-L310","documentation":"Raised by LoRAManager.validate_new_adapter when a LoRA adapter is loaded whose lora_name matches an adapter already registered in the manager. The manager keeps one adapter per unique name so that batch requests can resolve a name to a single set of weights, so duplicate names are rejected to avoid ambiguity.","triggerScenarios":"Calling _load_lora_adapter or _load_lora_adapter_from_tensors (e.g. via the /load_lora_adapter HTTP API or init_lora_adapters with startup --lora-paths) with a lora_ref whose lora_name equals one already present in self.lora_refs.","commonSituations":"Re-running a load request for the same adapter after a retry, listing the same adapter twice in startup lora_paths, or two different adapters given the same name.","solutions":["Unload the existing adapter first (unload_lora_adapter) and retry the load","Give the new adapter a distinct lora_name in the load request","Remove the duplicate entry from --lora-paths / lora_paths startup configuration"],"exampleFix":"# before\nmanager._load_lora_adapter(LoRARef(lora_path='ckpt', lora_name='adapter1'))  # second time\n# after\nmanager.unload_lora_adapter(manager.lora_refs_by_name['adapter1'])\nmanager._load_lora_adapter(LoRARef(lora_path='ckpt', lora_name='adapter1'))","handlingStrategy":"validation","validationCode":"names = {r.lora_name for r in manager.lora_refs.values()}\nassert lora_ref.lora_name not in names, f\"{lora_ref.lora_name} already loaded\"","typeGuard":null,"tryCatchPattern":"try:\n    manager._load_lora_adapter(lora_ref)\nexcept ValueError as e:\n    if 'already loaded' in str(e):\n        manager.unload_lora_adapter(...)  # then retry or skip\n    else:\n        raise","preventionTips":["Track loaded adapter names client-side before issuing loads","Make load requests idempotent by checking loaded list first","Don't retry load requests blindly after success"],"tags":["lora","duplicate","adapter","sglang"],"backgroundTag":"duplicate-resource-registration","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}