{"record":{"id":"31cb6847e4dd7ab7","repo":"sgl-project/sglang","slug":"mamba-state-layouts-differ-between-prefill-and-dec","errorCode":null,"errorMessage":"Mamba state layouts differ between prefill and decode (src item_lens={src_item_lens}, dst item_lens={dst_item_lens}) and no per-tensor dim metadata is available to reslice. With --enable-unified-memory, prefill and decode must both enable it and use equal attention TP sizes.","messagePattern":"Mamba state layouts differ between prefill and decode \\(src item_lens=(.+?), dst item_lens=(.+?)\\) and no per-tensor dim metadata is available to reslice\\. With --enable-unified-memory, prefill and decode must both enable it and use equal attention TP sizes\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/disaggregation/mooncake/conn.py","lineNumber":1290,"sourceCode":"                    else []\n                )\n                dst_state_layer_ids = (\n                    target_rank_registration_info.dst_state_layer_ids[i]\n                    if i < len(target_rank_registration_info.dst_state_layer_ids)\n                    else []\n                )\n            else:\n                dst_data_ptrs, dst_item_lens, dst_dim_per_tensor = [], [], []\n                dst_state_layer_ids = []\n            dst_indices = (\n                req.dst_state_indices[i] if i < len(req.dst_state_indices) else []\n            )\n\n            if st == StateType.MAMBA:\n                if (not src_dim_per_tensor or not dst_dim_per_tensor) and list(\n                    src_item_lens\n                ) != list(dst_item_lens):\n                    raise RuntimeError(\n                        \"Mamba state layouts differ between prefill and decode \"\n                        f\"(src item_lens={src_item_lens}, dst item_lens=\"\n                        f\"{dst_item_lens}) and no per-tensor dim metadata is \"\n                        \"available to reslice. With --enable-unified-memory, \"\n                        \"prefill and decode must both enable it and use equal \"\n                        \"attention TP sizes.\"\n                    )\n                if (\n                    target_rank_registration_info is not None\n                    and self.attn_tp_size\n                    != target_rank_registration_info.dst_attn_tp_size\n                ):\n                    rc = (\n                        self._send_mamba_state_slice(\n                            req,\n                            indices,\n                            src_data_ptrs,\n                            src_item_lens,","sourceCodeStart":1272,"sourceCodeEnd":1308,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/disaggregation/mooncake/conn.py#L1272-L1308","documentation":"In maybe_send_extra, mamba state tensors whose item_lens differ between prefill and decode cannot be resliced because no per-tensor dim metadata exists; the transfer is aborted with guidance to match TP sizes and flags.","triggerScenarios":"Hybrid model PD transfer where src and dst mamba item_lens differ AND src_dim_per_tensor/dst_dim_per_tensor are missing (older registration payloads).","commonSituations":"Mixed sglang versions between prefill and decode, mismatched --enable-unified-memory, or heterogeneous attention TP.","solutions":["Equalize attention TP sizes on prefill and decode","Enable --enable-unified-memory on both sides so dim metadata is available","Upgrade both instances to the same sglang version so registration carries per-tensor dims"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin identical sglang versions on both PD sides","Equalize attn TP and unified-memory flags for hybrid models"],"tags":["pd-disagg","mamba","tp-degree-mismatch","unified-memory"],"backgroundTag":"layout-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}