{"record":{"id":"8b367c2d8efef3cc","repo":"sgl-project/sglang","slug":"layer-types-contains-unknown-entries-bad-expect","errorCode":null,"errorMessage":"layer_types contains unknown entries {bad}; expected only 'full_attention' or 'sliding_attention'","messagePattern":"layer_types contains unknown entries (.+?); expected only 'full_attention' or 'sliding_attention'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/hardware_backend/mlx/models/muse_glimmer_mlx.py","lineNumber":305,"sourceCode":"\n        # NoPE layers are the full-attention layers; the rest slide.\n        derived_layer_types = [\n            \"full_attention\" if rope_flag == 0 else \"sliding_attention\"\n            for rope_flag in self.no_rope_layers\n        ]\n        if self.layer_types is None:\n            self.layer_types = derived_layer_types\n        else:\n            if len(self.layer_types) != self.num_hidden_layers:\n                raise ValueError(\n                    f\"layer_types has {len(self.layer_types)} entries but \"\n                    f\"num_hidden_layers is {self.num_hidden_layers}\"\n                )\n            bad = sorted(\n                set(self.layer_types) - {\"full_attention\", \"sliding_attention\"}\n            )\n            if bad:\n                raise ValueError(\n                    f\"layer_types contains unknown entries {bad}; expected only \"\n                    \"'full_attention' or 'sliding_attention'\"\n                )\n            if self.layer_types != derived_layer_types:\n                mismatches = [\n                    i\n                    for i, (got, want) in enumerate(\n                        zip(self.layer_types, derived_layer_types)\n                    )\n                    if got != want\n                ]\n                raise ValueError(\n                    \"layer_types disagrees with no_rope_layers (NoPE layers \"\n                    \"must be the full_attention layers) at layer indices \"\n                    f\"{mismatches}\"\n                )\n\n        if self.muse_glimmer_mlx_format is not None and (","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/hardware_backend/mlx/models/muse_glimmer_mlx.py#L287-L323","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"// before\n\"layer_types\": [\"full\", \"sliding\", \"sliding\"]\n// after\n\"layer_types\": [\"full_attention\", \"sliding_attention\", \"sliding_attention\"]","handlingStrategy":"validation","validationCode":"VALID = {\"full_attention\", \"sliding_attention\"}\nassert set(cfg.get(\"layer_types\") or []) <= VALID","typeGuard":"def valid_layer_types(cfg: dict) -> bool:\n    return set(cfg.get(\"layer_types\") or []) <= {\"full_attention\", \"sliding_attention\"}","tryCatchPattern":null,"preventionTips":["Use a linter/schema check on config.json before loading","Map foreign vocabularies to these two exact strings when porting"],"tags":["config-validation","layer-types","enum-values"],"backgroundTag":"invalid-enum-value-in-config","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}