sgl-project/sglang · error · ValueError

No model architectures are specified

Error message

No model architectures are specified

What it means

The MindSpore model loader requires at least one architecture in config.architectures to select an implementation from sgl_mindspore.models. An empty/missing list fails immediately with this ValueError.

Source

Thrown at python/sglang/srt/models/mindspore.py:38

_is_npu = is_npu()

if _is_npu:
    import mindspore as ms
    import numpy as np
    import torch_npu
    from mindspore import Tensor, mint, mutable

logger = logging.getLogger(__name__)


def _get_arch_from_config(config):
    mindspore_models = import_model_classes("sgl_mindspore.models")
    architectures = getattr(config, "architectures", [])
    if isinstance(architectures, str):
        architectures = [architectures]
    if not architectures:
        raise ValueError("No model architectures are specified")
    for arch in architectures:
        if arch in mindspore_models:
            return mindspore_models[arch]
    raise ValueError(f"Unsupported arch {architectures}")


def tensor_torch2ms(x: torch.Tensor):
    if x is None or not isinstance(x, torch.Tensor):
        return x

    # torch tensor -> dlpack -> mindspore tensor
    pt_dlpack = torch.utils.dlpack.to_dlpack(x)
    ms_tensor = ms.utils.dlpack.from_dlpack(pt_dlpack)
    return ms_tensor


def tensor_ms2torch(x: ms.Tensor):
    if x is None or not isinstance(x, ms.Tensor):

View on GitHub (pinned to 0132848349)

Solutions

  1. Add the architecture name to config.json, e.g. "architectures": ["MiMoV2ForCausalLM"]
  2. Verify the config file passed to the loader is the full model config, not a partial/truncated one
  3. If loading from a dict, ensure 'architectures' is a non-empty list of supported class names

Example fix

// before
{}
// after
{"architectures": ["SomeMindSporeModelForCausalLM"]}
Defensive patterns

Strategy: validation

Validate before calling

archs = getattr(config, 'architectures', None) or []
if isinstance(archs, str):
    archs = [archs]
if not archs:
    raise SystemExit('config.json is missing "architectures"')

Type guard

def has_architectures(cfg) -> bool:
    a = getattr(cfg, 'architectures', None)
    return bool(a) and bool(a if isinstance(a, list) else [a])

Prevention

When it happens

Trigger: Calling get_arch or get_model_config_for_expert_location with a config whose 'architectures' field is absent, empty, or an empty string.

Common situations: Hand-written or stripped config.json missing the architectures key; configs from tools that drop metadata; passing a raw HF config dict without architectures.

Related errors


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