sgl-project/sglang · error · ValueError

Didn't find any LoRA adapters when trying to evict LRU LoRA

Error message

Didn't find any LoRA adapters when trying to evict LRU LoRA adapter. LoRA registry is: {self.lora_registry._registry}

What it means

While evicting the least-recently-used LoRA adapter to stay under max_loaded_loras, the registry reported no evictable (non-pinned) adapter even though the limit was exceeded.

Source

Thrown at python/sglang/srt/managers/tokenizer_control_mixin.py:654

                result = _merge_lora_update_results(
                    await self.update_lora_adapter_communicator(obj)
                )

                # Register the LoRA adapter only after loading is successful.
                if result.success:
                    await self.lora_registry.register(new_adapter)
                    self.lora_ref_cache[obj.lora_name] = new_adapter

                if self.server_args.max_loaded_loras is not None:
                    while (
                        self.lora_registry.num_registered_loras
                        > self.server_args.max_loaded_loras
                    ):
                        lru_lora_name = await self.lora_registry.lru_lora_name(
                            exclude_pinned=True
                        )
                        if lru_lora_name is None:
                            raise ValueError(
                                "Didn't find any LoRA adapters when trying to evict LRU LoRA adapter. "
                                f"LoRA registry is: {self.lora_registry._registry}"
                            )

                        logger.info(
                            f"Unloading least recently used LoRA adapter '{lru_lora_name}' "
                            f"(current number of adapters: {self.lora_registry.num_registered_loras}, "
                            f"max allowed: {self.server_args.max_loaded_loras})"
                        )

                        unload_result = await self._unload_lora_adapter_locked(
                            UnloadLoRAAdapterReqInput(lora_name=lru_lora_name)
                        )
                        if not unload_result.success:
                            raise ValueError(
                                f"Error while unloading LRU LoRA adapter '{lru_lora_name}': "
                                f"{unload_result.error_message}"
                            )

View on GitHub (pinned to 0132848349)

Solutions

  1. Raise --max-loaded-loras above the number of pinned adapters
  2. Unpin or explicitly unload adapters you no longer need
  3. Report if counts disagree with the logged registry state

Example fix

# before
--enable-lora --max-loaded-loras 2  # with 3 pinned adapters
# after
--enable-lora --max-loaded-loras 8
Defensive patterns

Strategy: validation

Validate before calling

pinned = count_pinned(lora_registry)
assert pinned <= server_args.max_loaded_loras, 'raise --max-loaded-loras or unpin'

Try / catch

try:
    await client.load_lora_adapter(req)
except ValueError as e:
    if 'evict LRU' in str(e):
        increase_max_loaded_loras_or_unload_manually()
    raise

Prevention

When it happens

Trigger: load_lora_adapter exceeds max_loaded_loras but lru_lora_name(exclude_pinned=True) returns None — i.e. all loaded adapters are pinned, or the registry/counters are out of sync.

Common situations: Loading more pinned LoRA adapters than max_loaded_loras; adapter count leaking after failed loads.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/770de294acd5d948. Report an issue: GitHub.