sgl-project/sglang · critical · ValueError

num nextn_predict_layers is not in the config

Error message

num nextn_predict_layers is not in the config

What it means

Same nextn-layer resolution requirement as bailing_moe, in the linear-attention variant: load_weights needs num_nextn_predict_layers in the config to derive the MTP layer index, otherwise it raises.

Source

Thrown at python/sglang/srt/models/bailing_moe_linear.py:1406

            weight_loader = getattr(
                param, "weight_loader", BailingMoELinearAttention.weight_direct_load
            )
            weight_loader = weight_loader_with_alias(name)(weight_loader)
            weight_loader(param, loaded_weight)
            return

        if is_nextn:
            if hasattr(self.config, "num_nextn_predict_layers"):
                num_nextn_layers = self.config.num_nextn_predict_layers
                assert num_nextn_layers == 1, "Only 1 nextn layer is supported"
                # compatible with old design
                nextn_layer_id = (
                    0
                    if self.config.num_hidden_layers == 1
                    else self.config.num_hidden_layers
                )
            else:
                raise ValueError("num nextn_predict_layers is not in the config")

        stacked_params_mapping = [
            # (param_name, shard_name, shard_id)
            ("gate_up_proj", "gate_proj", 0),
            ("gate_up_proj", "up_proj", 1),
        ]
        expert_params_mapping = FusedMoE.make_expert_params_mapping(
            ckpt_gate_proj_name="gate_proj",
            ckpt_down_proj_name="down_proj",
            ckpt_up_proj_name="up_proj",
            num_experts=self.config.num_experts,
        )

        if is_nextn:
            nextn_layer_prefix = f"model.layers.{nextn_layer_id}"
            nextn_spec_weight_names = [
                "final_layernorm",
                "eh_proj",

View on GitHub (pinned to 0132848349)

Solutions

  1. Add "num_nextn_predict_layers": 1 to config.json
  2. Ensure explicit nextn layer index config is present
  3. Disable MTP if unused

Example fix

// before
{ "num_hidden_layers": 48 }
// after
{ "num_hidden_layers": 48, "num_nextn_predict_layers": 1 }
Defensive patterns

Strategy: validation

Validate before calling

assert hasattr(config, "num_nextn_predict_layers")

Prevention

When it happens

Trigger: Loading a bailing_moe_linear checkpoint with nextn/MTP weights while config.json lacks num_nextn_predict_layers.

Common situations: Hand-built speculative configs; checkpoints saved before the field was standardized.

Related errors


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