{"record":{"id":"d673cb5114484b9b","repo":"sgl-project/sglang","slug":"failed-to-load-lora-adapter-lora-ref-lora-name-a","errorCode":null,"errorMessage":"Failed to load LoRA adapter {lora_ref.lora_name} as a pinned adapter. It is not allowed to pin all slots in the LoRA memory pool to avoid starvation for unpinned adapters and base models. Please increase your `--max-loras-per-batch` or load it as unpinned LoRA adapters.","messagePattern":"Failed to load LoRA adapter (.+?) as a pinned adapter\\. It is not allowed to pin all slots in the LoRA memory pool to avoid starvation for unpinned adapters and base models\\. Please increase your `--max-loras-per-batch` or load it as unpinned LoRA adapters\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/lora/lora_manager.py","lineNumber":314,"sourceCode":"            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            )\n\n        # Ensure pinned LoRA adapters does not exceed maximal limit or cause starvation.\n        if lora_ref.pinned and self.num_pinned_loras >= self.max_loras_per_batch - 1:\n            raise ValueError(\n                f\"Failed to load LoRA adapter {lora_ref.lora_name} as a pinned adapter. It is not allowed to pin all slots \"\n                \"in the LoRA memory pool to avoid starvation for unpinned adapters and base models. Please increase your \"\n                \"`--max-loras-per-batch` or load it as unpinned LoRA adapters.\"\n            )\n\n    def unload_lora_adapter(self, lora_ref: LoRARef) -> LoRAUpdateOutput:\n        logger.info(\n            f\"LoRA adapter unloading starts: {lora_ref}. \"\n            f\"avail mem={get_available_gpu_memory(self.device.type, self.device.index):.2f} GB\"\n        )\n        result = self._unload_lora_adapter(lora_ref)\n        logger.info(\n            f\"LoRA adapter unloading completes: {lora_ref}. \"\n            f\"avail mem={get_available_gpu_memory(self.device.type, self.device.index):.2f} GB\"\n        )\n        return result\n\n    def _unload_lora_adapter(self, lora_ref: LoRARef) -> LoRAUpdateOutput:","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/lora/lora_manager.py#L296-L332","documentation":"Raised when loading a pinned LoRA adapter would occupy every slot in the LoRA memory pool. Pinned adapters permanently hold pool slots; the guard requires num_pinned_loras < max_loras_per_batch - 1 so at least one slot stays free for unpinned adapters and base-model requests, preventing starvation.","triggerScenarios":"Loading a LoRARef with pinned=True when self.num_pinned_loras already equals max_loras_per_batch - 1 (set by --max-lloras-per-batch / --max-loras-per-batch).","commonSituations":"Pinning several hot adapters at startup and then pinning one more, filling all slots allowed by a small --max-loras-per-batch value.","solutions":["Increase --max-loras-per-batch so pinned adapters leave a free slot","Load the adapter as unpinned instead of pinned","Unpin/unload an existing pinned adapter before pinning the new one"],"exampleFix":"# before\n--enable-lora --max-loras-per-batch 2  # pin 2nd adapter fails\n# after\n--enable-lora --max-loras-per-batch 4","handlingStrategy":"validation","validationCode":"if lora_ref.pinned:\n    assert manager.num_pinned_loras < manager.max_loras_per_batch - 1, \"no slot left for another pinned LoRA\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep pinned count at least one below --max-loras-per-batch","Budget pinned slots before startup based on your hot-adapter set","Prefer unpinned for rarely used adapters"],"tags":["lora","pinned","capacity","config","sglang"],"backgroundTag":"resource-capacity-exceeded","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}