{"record":{"id":"287ab1085595edb7","repo":"sgl-project/sglang","slug":"domain-id-must-be-non-negative-got-domain-id","errorCode":null,"errorMessage":"domain_id must be non-negative, got {domain_id}","messagePattern":"domain_id must be non-negative, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py","lineNumber":635,"sourceCode":"                    \"action_mode is set but the loaded Cosmos3 checkpoint has no \"\n                    \"action modality (action_gen is False).\"\n                )\n            self._prepare_action_latents(batch, generator, device, dtype)\n        return batch\n\n    def component_uses(\n        self, server_args: ServerArgs, stage_name: str | None = None\n    ) -> list[ComponentUse]:\n        return [ComponentUse(self._component_stage_name(stage_name), \"vae\")]\n\n    @staticmethod\n    def _resolve_domain_id(batch: Req) -> int:\n        \"\"\"Resolve action embodiment domain ID; required for action generation.\"\"\"\n        domain_id = getattr(batch.sampling_params, \"domain_id\", None)\n        if domain_id is not None:\n            domain_id = int(domain_id)\n            if domain_id < 0:\n                raise ValueError(f\"domain_id must be non-negative, got {domain_id}\")\n            return domain_id\n        domain_name = getattr(batch.sampling_params, \"domain_name\", None)\n        if domain_name:\n            key = str(domain_name).strip().lower()\n            if key not in EMBODIMENT_TO_DOMAIN_ID:\n                raise ValueError(\n                    f\"Unknown action domain name {domain_name!r}. \"\n                    f\"Valid names: {sorted(EMBODIMENT_TO_DOMAIN_ID)}\"\n                )\n            return EMBODIMENT_TO_DOMAIN_ID[key]\n        raise ValueError(\n            \"Cosmos3 action generation requires --domain-id or --domain-name.\"\n        )\n\n    def _prepare_action_latents(\n        self,\n        batch: Req,\n        generator,","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py#L617-L653","documentation":"Action generation requires identifying an embodiment domain via sampling_params.domain_id. Explicit domain IDs must be non-negative integers because they index the domain embedding table; negative values are rejected.","triggerScenarios":"Passing sampling_params.domain_id = -1 (or any negative int) when action_mode is set; _resolve_domain_id converts to int then checks < 0.","commonSituations":"Using -1 or 0-based-vs-1-based confusion as a sentinel for 'unspecified'; passing a numpy int that evaluates negative after int() coercion.","solutions":["Pass a valid non-negative domain_id (see EMBODIMENT_TO_DOMAIN_ID values)","Omit domain_id and use domain_name instead so it is looked up from the registry","Use a sentinel like None rather than -1 for 'unspecified'"],"exampleFix":"# before\nsp.domain_id = -1\n\n# after\nsp.domain_id = None\nsp.domain_name = 'franka'","handlingStrategy":"validation","validationCode":"if sp.domain_id is not None:\n    assert int(sp.domain_id) >= 0, 'domain_id must be non-negative'","typeGuard":"def valid_domain_id(v) -> bool:\n    return v is None or (isinstance(v, int) and not isinstance(v, bool) and v >= 0)","tryCatchPattern":null,"preventionTips":["Use None, never -1, as the 'unspecified' sentinel","Prefer domain_name lookups over raw numeric IDs"],"tags":["cosmos3","action-generation","domain-id","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}