{"record":{"id":"d94cad9cab09972a","repo":"sgl-project/sglang","slug":"destination-kv-descriptors-do-not-match-prefill-pp","errorCode":null,"errorMessage":"Destination KV descriptors do not match prefill pp configuration","messagePattern":"Destination KV descriptors do not match prefill pp configuration","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/disaggregation/mori/conn.py","lineNumber":861,"sourceCode":"\n    def _get_mha_mem_desc_slices(\n        self, dst_mem_descs: List[MemoryDesc]\n    ) -> tuple[\n        List[MemoryDesc], List[MemoryDesc], List[MemoryDesc], List[MemoryDesc], int\n    ]:\n        src_descs = self.kv_mem_descs\n        if not src_descs:\n            raise RuntimeError(\"KV memory descriptors are empty on prefill side\")\n\n        num_local_layers = len(src_descs) // 2\n        src_k_descs = src_descs[:num_local_layers]\n        src_v_descs = src_descs[num_local_layers:]\n\n        start_layer = self.kv_args.prefill_start_layer\n        end_layer = start_layer + num_local_layers\n        dst_total_layers = len(dst_mem_descs) // 2\n        if len(dst_mem_descs) < 2 or end_layer > dst_total_layers:\n            raise ValueError(\n                \"Destination KV descriptors do not match prefill pp configuration\"\n            )\n        dst_k_descs = dst_mem_descs[start_layer:end_layer]\n        dst_v_descs = dst_mem_descs[\n            dst_total_layers + start_layer : dst_total_layers + end_layer\n        ]\n        return src_k_descs, src_v_descs, dst_k_descs, dst_v_descs, num_local_layers\n\n    def _get_mla_mem_desc_slices(\n        self, dst_mem_descs: List[MemoryDesc]\n    ) -> tuple[List[MemoryDesc], List[MemoryDesc], int]:\n        src_descs = self.kv_mem_descs\n        num_local_layers = len(src_descs)\n        start_layer = self.kv_args.prefill_start_layer\n        end_layer = start_layer + num_local_layers\n        if end_layer > len(dst_mem_descs):\n            raise ValueError(\n                \"Destination MLA KV descriptors do not match prefill pp configuration\"","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/disaggregation/mori/conn.py#L843-L879","documentation":"When slicing destination descriptors for MHA transfer, the prefill's [start_layer, start_layer+num_local_layers) window must fit within the destination's total layer count; otherwise the PP configuration is inconsistent and ValueError is raised.","triggerScenarios":"len(dst_mem_descs)//2 < end_layer or fewer than 2 dst descriptors — decode side has fewer KV layers than the prefill's slice requires.","commonSituations":"Prefill and decode launched with different --pp-size or layer partitioning, or a decode model with fewer layers (wrong checkpoint).","solutions":["Match pipeline-parallel layer ranges between prefill and decode (same pp size and layer counts)","Confirm both sides load the same model checkpoint","Check prefill_start_layer in kv_args matches the deployment topology"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"dst_total = len(dst_mem_descs) // 2\nassert dst_total >= prefill_start_layer + num_local_layers, (dst_total, prefill_start_layer, num_local_layers)","typeGuard":null,"tryCatchPattern":"catch ValueError at send time; fail fast with a clear PD topology mismatch message","preventionTips":["Share one topology config (pp size, layer count, checkpoint) between PD instances","Validate layer windows at registration handshake"],"tags":["mori","pipeline-parallel","layer-mismatch","kv-cache"],"backgroundTag":"layer-count-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}