sgl-project/sglang · error · RuntimeError

Failed to set LoRA adapter: {str(e)}

Error message

Failed to set LoRA adapter: {str(e)}

What it means

RuntimeError wrapper from set_lora when the POST to the LoRA endpoint fails (connection error or non-2xx status within a 30s timeout). The adapter was not applied.

Source

Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:496

            "lora_nickname": lora_nickname,
            "target": target,
        }

        # Add optional lora_path if provided
        if lora_path:
            payload["lora_path"] = lora_path

        try:
            response = requests.post(
                f"{self.base_url}/set_lora",
                json=payload,
                headers=self.headers,
                timeout=30,
            )
            response.raise_for_status()
            return response.json()
        except requests.exceptions.RequestException as e:
            raise RuntimeError(f"Failed to set LoRA adapter: {str(e)}")

    def unset_lora(
        self,
        target: str = "all",
    ) -> Dict[str, Any]:
        """
        Unset (unmerge) LoRA weights from the base model.

        Args:
            target: same as set_lora

        Returns:
            Dictionary containing the API response with status and message
        """
        # Prepare request payload
        payload: Dict[str, Any] = {
            "target": target,
        }

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the embedded status: 404 = nickname unknown or endpoint missing, 500 = loading failure.
  2. Verify the nickname against the server's LoRA listing.
  3. Increase the 30s timeout if large adapters load slowly.
  4. Check server logs for weight-loading errors.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    api.set_lora(nickname, target='all')
except RuntimeError as e:
    if '404' in str(e): raise ValueError(f'unknown LoRA {nickname}')
    time.sleep(2); api.set_lora(nickname, target='all')

Prevention

When it happens

Trigger: Server down/unreachable, unknown lora_nickname rejected with 4xx, or the LoRA endpoint returning 500 while loading the adapter.

Common situations: Nickname not registered server-side; LoRA weights missing on the server; endpoint absent in older server versions; request exceeding 30s while weights load.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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