{"record":{"id":"d12fb36ee5c933e7","repo":"sgl-project/sglang","slug":"pd-state-transfer-failed-kv-args-state-types-is-e","errorCode":null,"errorMessage":"PD state transfer failed: kv_args.state_types is empty but state_indices were provided","messagePattern":"PD state transfer failed: kv_args\\.state_types is empty but state_indices were provided","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/disaggregation/mori/conn.py","lineNumber":1195,"sourceCode":"                str(aux_index).encode(\"ascii\"),\n                struct.pack(\">I\", len(data)),\n                data,\n            ]\n        )\n\n    def send_state(\n        self,\n        peer_info: KVArgsRegisterInfo,\n        src_state_indices: List[npt.NDArray[np.int32]],\n        dst_state_indices: List[npt.NDArray[np.int32]],\n    ) -> List[TransferStatus]:\n        # Guard: no local state tensors -> no-op (e.g. SWA layers=0 on this PP rank)\n        if not self.state_mem_descs:\n            return []\n\n        state_types = self.kv_args.state_types\n        if not state_types:\n            raise RuntimeError(\n                \"PD state transfer failed: kv_args.state_types is empty but \"\n                \"state_indices were provided\"\n            )\n\n        if len(peer_info.dst_state_mem_descs) != len(self.state_mem_descs):\n            raise RuntimeError(\n                f\"PD state transfer failed: state component count mismatch \"\n                f\"(local={len(self.state_mem_descs)}, \"\n                f\"remote={len(peer_info.dst_state_mem_descs)})\"\n            )\n\n        src_state_item_lens = self.kv_args.state_item_lens\n        src_state_dim_per_tensor = self.kv_args.state_dim_per_tensor\n\n        statuses: List[TransferStatus] = []\n        for i, st in enumerate(state_types):\n            src_indices = src_state_indices[i] if i < len(src_state_indices) else None\n            dst_indices = dst_state_indices[i] if i < len(dst_state_indices) else None","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/disaggregation/mori/conn.py#L1177-L1213","documentation":"send_state was invoked with state_indices to transfer (e.g. Mamba/SWA recurrent state for hybrid models), but kv_args.state_types is empty on this instance. The library refuses to transfer state whose type taxonomy was never declared, since it cannot map indices to state components without it.","triggerScenarios":"Calling send_kvcache/_submit_kv_transfer for a hybrid model where state_mem_descs is non-empty (state pool allocated) but the engine never populated kv_args.state_types — e.g. a version/config path that registers state buffers without declaring their types.","commonSituations":"Upgrading SGLang where state_types was added to KVArgs but the custom attention backend or model integration was not updated to fill it; enabling a hybrid (Mamba/GDN/SWA) model with an attention backend that skips state type registration.","solutions":["Ensure the attention backend/model integration populates kv_args.state_types alongside state memory descriptors (update SGLang or your backend adapter)","Check that the hybrid state configuration (e.g. --mamba-full-memory-ratio, SWA settings) that enables state tracking also declares its types","Verify both prefill and decode run the same SGLang version so state_types is symmetric"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if state_indices is not None and state_indices.numel() > 0:\n    assert kv_args.state_types, (\n        \"state_indices provided but kv_args.state_types is empty\"\n    )\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the attention backend fills kv_args.state_types whenever it allocates state buffers","Keep prefill/decode SGLang versions in lockstep","Add a unit test asserting state_types non-empty for hybrid models"],"tags":["disaggregation","hybrid-model","mamba","state-transfer","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}