sgl-project/sglang · error · ValueError

Missing required field: sm_group_num

Error message

Missing required field: sm_group_num

What it means

load_pdmux_config parses the PD-multiplexing YAML config; sm_group_num is mandatory because the SM partitioner needs to know how many stream groups to create. Absence means the config file is incomplete.

Source

Thrown at python/sglang/srt/multiplex/pdmux_context.py:33

class PDMuxConfig:
    sm_group_num: int = 8
    manual_divisions: List[List[int]] = field(
        default_factory=list
    )  # [prefill_sm, decode_sm, decode_bs_threshold]
    split_forward_token_budget: int = 65536
    decode_bs_divisor: int = 36


def load_pdmux_config(config_path: str) -> PDMuxConfig:
    """Load pdmux configuration from YAML file into a dataclass."""
    if not config_path:
        return PDMuxConfig()

    with open(config_path, "r") as f:
        raw = yaml.safe_load(f)

    if "sm_group_num" not in raw:
        raise ValueError("Missing required field: sm_group_num")

    if raw["sm_group_num"] < 3:
        raise ValueError("sm_group_num must be >= 3")

    manual_divisions = raw.get("manual_divisions", [])

    expected = raw["sm_group_num"] - 2
    if manual_divisions and len(manual_divisions) != expected:
        raise ValueError(
            f"manual_divisions must have {expected} entries, "
            f"but got {len(manual_divisions)}"
        )

    return PDMuxConfig(
        sm_group_num=raw["sm_group_num"],
        manual_divisions=manual_divisions,
        split_forward_token_budget=raw.get("split_forward_token_budget", 65536),
        decode_bs_divisor=raw.get("decode_bs_divisor", 36),

View on GitHub (pinned to 0132848349)

Solutions

  1. Add sm_group_num: <N> (>=3) at the top level of the pdmux YAML
  2. Check spelling/case of the key against the sglang pdmux config schema
  3. Regenerate the config from a known-good example shipped with sglang

Example fix

# before
# pdmux.yaml
manual_divisions: [...]
# after
sm_group_num: 4
manual_divisions: [...]
Defensive patterns

Strategy: validation

Validate before calling

import yaml
raw = yaml.safe_load(open(cfg_path))
assert 'sm_group_num' in raw, 'pdmux config missing sm_group_num'

Try / catch

try:
    cfg = load_pdmux_config(path)
except ValueError as e:
    raise SystemExit(f'bad pdmux config: {e}')

Prevention

When it happens

Trigger: Calling init_pdmux with a config path whose YAML lacks the top-level sm_group_num key.

Common situations: Hand-written or template config with a typo (e.g. sm_groups_num); a config generated for an older sglang version; empty YAML file that parses to None-like dict without the key.

Related errors


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