sgl-project/sglang · error · ValueError
Received request with {len(unique_lora_paths)} unique loras
Error message
Received request with {len(unique_lora_paths)} unique loras requested but max loaded loras is {get_lora().max_loaded_loras} What it means
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.
Source
Thrown at python/sglang/srt/managers/tokenizer_manager.py:3346
raise ValueError(
f"LoRA adapter '{first_adapter}' was requested, but LoRA is not enabled. "
"Please launch the server with --enable-lora flag and preload adapters "
"using --lora-paths or /load_lora_adapter endpoint."
)
await self._resolve_lora_path(obj)
async def _resolve_lora_path(self, obj: Union[GenerateReqInput, EmbeddingReqInput]):
if isinstance(obj.lora_path, str):
unique_lora_paths = set([obj.lora_path])
else:
unique_lora_paths = set(obj.lora_path)
if (
get_lora().max_loaded_loras is not None
and len(unique_lora_paths) > get_lora().max_loaded_loras
):
raise ValueError(
f"Received request with {len(unique_lora_paths)} unique loras requested "
f"but max loaded loras is {get_lora().max_loaded_loras}"
)
# Reload all existing LoRA adapters that have been dynamically unloaded
unregistered_loras = await self.lora_registry.get_unregistered_loras(
unique_lora_paths
)
for lora_path in unregistered_loras:
if lora_path is None:
continue
if lora_path not in self.lora_ref_cache:
raise ValueError(
f"Got LoRA adapter that has never been loaded: {lora_path}\n"
f"All loaded adapters: {self.lora_ref_cache.keys()}."
)
View on GitHub (pinned to 0132848349)
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
Example fix
# before python -m sglang.launch_server --model-path M --enable-lora --max-loras 1 # request: lora_path=["a","b"] # after python -m sglang.launch_server --model-path M --enable-lora --max-loras 4 # or split into two requests, one per adapter
Defensive patterns
Strategy: validation
Validate before calling
max_loaded = get_max_loaded_loras() # from server info
uniq = {p for p in lora_paths if p}
if len(uniq) > max_loaded:
lora_paths = split_or_reduce(uniq, max_loaded) Type guard
def fits_lora_limit(paths: list, limit: int) -> bool:
return len({p for p in paths if p}) <= limit Try / catch
try:
out = engine.generate(prompt, lora_path=paths)
except ValueError as e:
if "max loaded loras" in str(e):
# chunk the batch by unique adapter
...
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- LoRA adapter '{first_adapter}' was requested, but LoRA is no
- Block sparse tensors{context} require BLOCK_SIZE_KV={base_n_
- Invalid arch format: {arch_str}
- LoRA batch_info must provide max_len or seg_lens.
- LoRA batch_info must provide max_len or seg_lens.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c7c6735e7a477a3d.
Report an issue: GitHub.