sgl-project/sglang · error · ValueError

Native diffusion LoRA loading requires a safetensors file, g

Error message

Native diffusion LoRA loading requires a safetensors file, got {selected_file!r}

What it means

After resolving a LoRA weight (local or remote inventory), maybe_download_lora enforces that the selected file is a .safetensors file because the native diffusion LoRA loader only parses safetensors. Any other extension (.bin, .ckpt, .pt) raises ValueError.

Source

Thrown at python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py:653

        if weight_name is not None:
            target = os.path.join(local_path, weight_name)
            if not os.path.isfile(target):
                raise FileNotFoundError(
                    f"Specified lora_weight_name '{weight_name}' not found in "
                    f"{local_path}"
                )
            return target
        guessed = _best_guess_weight_name(local_path, file_extension=".safetensors")
        if guessed is None and current_platform.is_rocm():
            guessed = _best_guess_weight_name(
                model_name_or_path, file_extension=".safetensors"
            )
        return os.path.join(local_path, guessed)

    resolved_weight = resolve_weight(model_name_or_path, weight_name=weight_name)
    selected_file = resolved_weight.selected_file
    if not selected_file.endswith(".safetensors"):
        raise ValueError(
            "Native diffusion LoRA loading requires a safetensors file, got "
            f"{selected_file!r}"
        )

    source = resolved_weight.inventory.source
    if source.kind == "local":
        assert source.local_path is not None
        if os.path.isfile(source.local_path):
            return source.local_path
        return os.path.join(source.local_path, selected_file)

    assert source.repo_id is not None
    allow_patterns = ["*.json", selected_file]
    selected_parent = os.path.dirname(selected_file)
    if selected_parent:
        allow_patterns.insert(1, f"{selected_parent}/*.json")
    local_path = maybe_download_model(
        source.repo_id,

View on GitHub (pinned to 0132848349)

Solutions

  1. Convert the LoRA to safetensors (e.g. diffusers' script or safetensors conversion tools) and specify the new weight name
  2. Download/use the safetensors variant of the same LoRA if the repo offers one

Example fix

# before
load_lora_adapter(repo, weight_name="pytorch_lora_weights.bin")
# after
# convert first: python convert_lora_to_safetensors ...
load_lora_adapter(repo, weight_name="pytorch_lora_weights.safetensors")
Defensive patterns

Strategy: validation

Validate before calling

assert selected.endswith('.safetensors'), f'need safetensors, got {selected}'

Try / catch

try:
    load_lora_adapter(...)
except ValueError as e:
    if 'requires a safetensors file' in str(e):
        convert_to_safetensors(selected_file)

Prevention

When it happens

Trigger: Calling load_lora_adapter where resolve_weight picks a .bin/.ckpt/.pt file — either because weight_name pointed at one, or the best-guess fell through to a non-safetensors file (also seen with ROCm fallback paths).

Common situations: Old diffusers LoRAs shipped as pytorch_lora_weights.bin; checkpoints from civitai in .ckpt format; ROCm envs where safetensors guess fails and a .bin is chosen.

Related errors


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