{"record":{"id":"c7c6735e7a477a3d","repo":"sgl-project/sglang","slug":"received-request-with-len-unique-lora-paths-uni","errorCode":null,"errorMessage":"Received request with {len(unique_lora_paths)} unique loras requested but max loaded loras is {get_lora().max_loaded_loras}","messagePattern":"Received request with (.+?) unique loras requested but max loaded loras is (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/tokenizer_manager.py","lineNumber":3346,"sourceCode":"            raise ValueError(\n                f\"LoRA adapter '{first_adapter}' was requested, but LoRA is not enabled. \"\n                \"Please launch the server with --enable-lora flag and preload adapters \"\n                \"using --lora-paths or /load_lora_adapter endpoint.\"\n            )\n\n        await self._resolve_lora_path(obj)\n\n    async def _resolve_lora_path(self, obj: Union[GenerateReqInput, EmbeddingReqInput]):\n        if isinstance(obj.lora_path, str):\n            unique_lora_paths = set([obj.lora_path])\n        else:\n            unique_lora_paths = set(obj.lora_path)\n\n        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","sourceCodeStart":3328,"sourceCodeEnd":3364,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/tokenizer_manager.py#L3328-L3364","documentation":"A single request referenced more unique LoRA adapters than the server's max_loaded_loras limit. The tokenizer manager counts distinct paths in the request's lora_path list and rejects it if the count exceeds the configured maximum number of concurrently loaded adapters.","triggerScenarios":"Passing a list of lora_path values containing more unique adapters than --max-loaded-loras (derived from max_loras / lora capacity) in one generate request.","commonSituations":"Multi-LoRA batching with a long adapter list while server launched with default max_loras (often 1); raising client-side batch diversity without raising --max-loras/--max-loaded-loras; duplicate paths collapsing to fewer uniques than expected after refactoring.","solutions":["Relaunch the server with a higher --max-loras / --max-loaded-loras (and enough GPU memory via --lora-target-modules etc.)","Split the request so each generate call uses at most max_loaded_loras unique adapters","Deduplicate lora_path lists client-side before sending"],"exampleFix":"# before\npython -m sglang.launch_server --model-path M --enable-lora --max-loras 1\n# request: lora_path=[\"a\",\"b\"]\n\n# after\npython -m sglang.launch_server --model-path M --enable-lora --max-loras 4\n# or split into two requests, one per adapter","handlingStrategy":"validation","validationCode":"max_loaded = get_max_loaded_loras()  # from server info\nuniq = {p for p in lora_paths if p}\nif len(uniq) > max_loaded:\n    lora_paths = split_or_reduce(uniq, max_loaded)","typeGuard":"def fits_lora_limit(paths: list, limit: int) -> bool:\n    return len({p for p in paths if p}) <= limit","tryCatchPattern":"try:\n    out = engine.generate(prompt, lora_path=paths)\nexcept ValueError as e:\n    if \"max loaded loras\" in str(e):\n        # chunk the batch by unique adapter\n        ...\n    raise","preventionTips":["Set --max-loras to the maximum per-request adapter diversity you need","Deduplicate adapter paths before batching requests","Monitor adapter count per request in client middleware"],"tags":["lora","multi-lora","limits","configuration"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}