sgl-project/sglang · error · ValueError

SGLang currently only supports inferring LoRA target modules

Error message

SGLang currently only supports inferring LoRA target modules when a list of suffixes is provided in `target_modules` field of PEFT config. Please explicitly specify `--lora-target-modules` during server startup. You can specify `all` to enable all support modules types. 

What it means

Raised in init_lora_shapes when the resolved PEFT config's target_modules field is not a Python list. SGLang's inference of target modules only supports a list of module name suffixes; strings (regex or single names), dicts, or None all trigger this error asking for an explicit --lora-target-modules flag.

Source

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

                        logger.info(
                            "LoRA adapter '%s' uses target_modules='%s'. "
                            "Resolved to %s by inspecting the base model.",
                            self.lora_refs[lora_id].lora_name,
                            config.target_modules,
                            sorted(adapter_target_modules),
                        )
                        self.target_modules.update(adapter_target_modules)
                        continue
                else:
                    raise ValueError(
                        f"SGLang does not recognize target_modules="
                        f"'{config.target_modules}'. Please use a list of module "
                        "name suffixes in the adapter's PEFT config, or explicitly "
                        "specify --lora-target-modules during server startup."
                    )

            if not isinstance(config.target_modules, list):
                raise ValueError(
                    f"SGLang currently only supports inferring LoRA target modules when a list of "
                    "suffixes is provided in `target_modules` field of PEFT config. Please explicitly "
                    "specify `--lora-target-modules` during server startup. You can specify `all` to "
                    "enable all support modules types. "
                )

            adapter_target_modules = get_normalized_target_modules(
                config.target_modules
            )

            if target_modules is not None:
                # When `--lora-target-modules` is provided, validate adapter target modules is a subset of the specified target modules.
                if not adapter_target_modules.issubset(self.target_modules):
                    unsupported_modules = adapter_target_modules - self.target_modules
                    lora_name = self.lora_refs[lora_id].lora_name
                    raise ValueError(
                        f"LoRA adapter '{lora_name}' contains target modules {sorted(unsupported_modules)} "
                        f"that are not included in the specified --lora-target-modules {sorted(self.target_modules)}. "

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass --lora-target-modules at startup (suffix list or 'all')
  2. Rewrite adapter_config.json so target_modules is a JSON array of suffixes

Example fix

# before
{"target_modules": "q_proj"}
# after
{"target_modules": ["q_proj", "v_proj"]}
Defensive patterns

Strategy: type-guard

Validate before calling

assert isinstance(config.target_modules, list), 'target_modules must be a list of suffixes; pass --lora-target-modules'

Type guard

def is_suffix_list(value) -> bool:
    return isinstance(value, list) and bool(value) and all(isinstance(v, str) for v in value)

Prevention

When it happens

Trigger: init_state with an adapter whose target_modules is a string (single module or regex) or any non-list type, regardless of other content, because the isinstance(config.target_modules, list) check fails.

Common situations: PEFT versions that serialize target_modules as a string; hand-edited adapter configs; adapters targeting a single module stored as a bare string.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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