sgl-project/sglang · error · ValueError

Failed to load LoRA adapter {lora_ref.lora_name} because it

Error message

Failed to load LoRA adapter {lora_ref.lora_name} because it is already loaded

What it means

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.

Source

Thrown at python/sglang/srt/lora/lora_manager.py:292

    def validate_new_adapter(self, lora_config: LoRAConfig, lora_ref: LoRARef):
        """
        Validate if an adapter can be loaded into the current LoRA memory pool and generate error if it is incompatible.
        """
        if lora_config.lora_added_tokens_size > 0:
            raise ValueError(
                f"Failed to load {lora_ref.lora_name} because LoRA serving currently doesn't support adapters that add tokens to the vocabulary"
            )

        if lora_config.use_dora:
            raise ValueError(
                f"Failed to load {lora_ref.lora_name} because LoRA serving currently doesn't support DoRA adapters"
            )

        # Check if this LoRA adapter is already loaded
        for existing_lora_ref in self.lora_refs.values():
            if lora_ref.lora_name == existing_lora_ref.lora_name:
                raise ValueError(
                    f"Failed to load LoRA adapter {lora_ref.lora_name} because it is already loaded"
                )

            if lora_ref.lora_path == existing_lora_ref.lora_path:
                logger.warning(
                    f"{lora_ref.lora_path} is already loaded with name: {existing_lora_ref.lora_name}, "
                    f"but another copy is being loaded with name: {lora_ref.lora_name}"
                )

        # Check if the LoRA adapter shape is compatible with the current LoRA memory pool configuration.
        memory_pool = getattr(self, "memory_pool", None)
        incompatible = memory_pool and not memory_pool.can_support(lora_config)
        if incompatible:
            raise ValueError(
                f"LoRA adapter {lora_ref.lora_name} with rank {lora_config.r} is incompatible with the current "
                "LoRA memory pool configuration. Please ensure that the LoRA adapter's rank is within the configured "
                "`--max-lora-rank` and that the target modules are included in `--lora-target-modules`."
            )

View on GitHub (pinned to 0132848349)

Solutions

  1. Unload the existing adapter first (unload_lora_adapter) and retry the load
  2. Give the new adapter a distinct lora_name in the load request
  3. Remove the duplicate entry from --lora-paths / lora_paths startup configuration

Example fix

# before
manager._load_lora_adapter(LoRARef(lora_path='ckpt', lora_name='adapter1'))  # second time
# after
manager.unload_lora_adapter(manager.lora_refs_by_name['adapter1'])
manager._load_lora_adapter(LoRARef(lora_path='ckpt', lora_name='adapter1'))
Defensive patterns

Strategy: validation

Validate before calling

names = {r.lora_name for r in manager.lora_refs.values()}
assert lora_ref.lora_name not in names, f"{lora_ref.lora_name} already loaded"

Try / catch

try:
    manager._load_lora_adapter(lora_ref)
except ValueError as e:
    if 'already loaded' in str(e):
        manager.unload_lora_adapter(...)  # then retry or skip
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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