sgl-project/sglang · error · ValueError
layer_types contains unknown entries {bad}; expected only 'f
Error message
layer_types contains unknown entries {bad}; expected only 'full_attention' or 'sliding_attention' What it means
Each entry of an explicitly provided layer_types list must be exactly 'full_attention' or 'sliding_attention'. Any other string (typos, 'sliding', 'local', 'full') or non-string value fails the set-difference check and raises this error.
Source
Thrown at python/sglang/srt/hardware_backend/mlx/models/muse_glimmer_mlx.py:305
# NoPE layers are the full-attention layers; the rest slide.
derived_layer_types = [
"full_attention" if rope_flag == 0 else "sliding_attention"
for rope_flag in self.no_rope_layers
]
if self.layer_types is None:
self.layer_types = derived_layer_types
else:
if len(self.layer_types) != self.num_hidden_layers:
raise ValueError(
f"layer_types has {len(self.layer_types)} entries but "
f"num_hidden_layers is {self.num_hidden_layers}"
)
bad = sorted(
set(self.layer_types) - {"full_attention", "sliding_attention"}
)
if bad:
raise ValueError(
f"layer_types contains unknown entries {bad}; expected only "
"'full_attention' or 'sliding_attention'"
)
if self.layer_types != derived_layer_types:
mismatches = [
i
for i, (got, want) in enumerate(
zip(self.layer_types, derived_layer_types)
)
if got != want
]
raise ValueError(
"layer_types disagrees with no_rope_layers (NoPE layers "
"must be the full_attention layers) at layer indices "
f"{mismatches}"
)
if self.muse_glimmer_mlx_format is not None and (View on GitHub (pinned to 0132848349)
Solutions
- Replace every entry with exactly 'full_attention' or 'sliding_attention'
- Set layer_types to null and let it be derived from no_rope_layers
- If porting from another framework, map its vocabulary to these two strings programmatically
Example fix
// before "layer_types": ["full", "sliding", "sliding"] // after "layer_types": ["full_attention", "sliding_attention", "sliding_attention"]
Defensive patterns
Strategy: validation
Validate before calling
VALID = {"full_attention", "sliding_attention"}
assert set(cfg.get("layer_types") or []) <= VALID Type guard
def valid_layer_types(cfg: dict) -> bool:
return set(cfg.get("layer_types") or []) <= {"full_attention", "sliding_attention"} Prevention
- Use a linter/schema check on config.json before loading
- Map foreign vocabularies to these two exact strings when porting
When it happens
Trigger: Providing layer_types with misspelled or differently-named attention type strings, e.g. 'full' instead of 'full_attention' or 'sliding_window' instead of 'sliding_attention'.
Common situations: Porting configs from other codebases (vLLM/transformers) that use different attention-type vocabulary, hand-writing layer_types, or LLM-assisted config generation introducing inconsistent naming.
Related errors
- layer_types has {len(self.layer_types)} entries but num_hidd
- layer_types disagrees with no_rope_layers (NoPE layers must
- bad compress_ratio {compress_ratio}
- The requested FlashAttention forward configuration exceeds S
- flashinfer_sparse_mla supports only GLM DSA with FP8 KV cach
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/8b367c2d8efef3cc.
Report an issue: GitHub.