{"record":{"id":"949e82a4cb21e71a","repo":"sgl-project/sglang","slug":"invalid-component-residency-mode-raw-mode-r-for","errorCode":null,"errorMessage":"Invalid component residency mode {raw_mode!r} for {selector!r}; expected one of: {expected}","messagePattern":"Invalid component residency mode (.+?) for (.+?); expected one of: (.+?)","errorType":"validation","errorClass":"ComponentResidencyError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency.py","lineNumber":96,"sourceCode":"                parsed_entries.append((selector, mode))\n        entries = parsed_entries\n\n    normalized: dict[str, str] = {}\n    for raw_selector, raw_mode in entries:\n        if not isinstance(raw_selector, str) or not isinstance(raw_mode, str):\n            raise ComponentResidencyError(\n                \"Invalid component residency assignment: \"\n                f\"{raw_selector!r}={raw_mode!r}\"\n            )\n        selector = raw_selector.strip().replace(\"-\", \"_\").lower()\n        mode = raw_mode.strip().replace(\"_\", \"-\").lower()\n        if not selector:\n            raise ComponentResidencyError(\n                \"Component residency selector cannot be empty\"\n            )\n        if mode not in COMPONENT_RESIDENCY_MODES:\n            expected = \", \".join(sorted(COMPONENT_RESIDENCY_MODES))\n            raise ComponentResidencyError(\n                f\"Invalid component residency mode {raw_mode!r} for \"\n                f\"{selector!r}; expected one of: {expected}\"\n            )\n        normalized[selector] = mode\n\n    return normalized or None\n\n\ndef component_residency_selector_matches(component_name: str, selector: str) -> bool:\n    if selector == LAYERWISE_OFFLOAD_ALL_COMPONENTS:\n        return True\n    if selector == LAYERWISE_OFFLOAD_DIT_GROUP:\n        return is_dit_component_name(component_name)\n    if selector == LAYERWISE_OFFLOAD_TEXT_ENCODER_GROUP:\n        return is_text_encoder_component_name(component_name)\n    if selector == LAYERWISE_OFFLOAD_IMAGE_ENCODER_GROUP:\n        return is_image_encoder_component_name(component_name)\n    if selector == LAYERWISE_OFFLOAD_VAE_GROUP:","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency.py#L78-L114","documentation":"The mode part of COMPONENT=MODE must be one of the recognized COMPONENT_RESIDENCY_MODES; anything else is rejected with a message listing the valid modes (after normalizing '_' to '-').","triggerScenarios":"An assignment like \"vit=cp\" (typo), \"vit=CPU!\" or \"vit=host\" where the normalized mode isn't in COMPONENT_RESIDENCY_MODES (e.g. cpu, gpu, layerwise-offload, component-offload).","commonSituations":"Typos and case/separator variants (mostly auto-normalized); using mode names from a different library version where the mode set changed; guessing mode names instead of checking docs.","solutions":["Use one of the modes listed in the error message exactly","Check the COMPONENT_RESIDENCY_MODES constant in component_residency.py for your installed version's valid modes"],"exampleFix":"# before\n--component-residency vit=cp\n# after\n--component-residency vit=cpu","handlingStrategy":"validation","validationCode":"from sglang.multimodal_gen.runtime.managers.memory_managers.component_residency import COMPONENT_RESIDENCY_MODES\nfor tok in s.split(\",\"):\n    if \"=\" not in tok: continue\n    mode = tok.split(\"=\", 1)[1].strip().replace(\"_\", \"-\").lower()\n    if mode not in COMPONENT_RESIDENCY_MODES:\n        raise SystemExit(f\"bad mode {mode!r}; valid: {sorted(COMPONENT_RESIDENCY_MODES)}\")","typeGuard":"def is_valid_mode(mode: str) -> bool:\n    return mode.strip().replace(\"_\", \"-\").lower() in COMPONENT_RESIDENCY_MODES","tryCatchPattern":null,"preventionTips":["Copy mode names from the error message or the source constant, not from memory","Re-check modes after upgrading sglang"],"tags":["config","component-residency","parsing","enum"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}