{"record":{"id":"0f4657d11e4039c8","repo":"sgl-project/sglang","slug":"unexpected-compressed-mla-dst-kv-ptrs-length-len","errorCode":null,"errorMessage":"Unexpected compressed-MLA dst_kv_ptrs length {len(dst_kv_ptrs)}; expected either {kv_layout_len} (kv_data) or swa_L + {2 * c4_full} (state_data) given compression_ratios (c4={c4_full}, c128={c128_full}, total={len(mla_ratios)}).","messagePattern":"Unexpected compressed-MLA dst_kv_ptrs length (.+?); expected either (.+?) \\(kv_data\\) or swa_L \\+ (.+?) \\(state_data\\) given compression_ratios \\(c4=(.+?), c128=(.+?), total=(.+?)\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/disaggregation/common/conn.py","lineNumber":1032,"sourceCode":"        if (\n            state_type not in (StateType.SWA, StateType.SWA_RING, StateType.C128_STATE)\n            and len(dst_kv_ptrs) == kv_layout_len\n        ):\n            sliced_dst = (\n                list(dst_kv_ptrs[c4_off_s:c4_off_e])\n                + list(dst_kv_ptrs[c4_full + c4_off_s : c4_full + c4_off_e])\n                + list(dst_kv_ptrs[2 * c4_full + c128_off_s : 2 * c4_full + c128_off_e])\n            )\n            return src_kv_ptrs, sliced_dst\n\n        # SWA state-data layout. ``swa_L`` is derived from the actual dst\n        # length so we tolerate cases where the SWA pool has fewer buffers\n        # than ``len(mla_ratios)`` (e.g. nextn padding). C128 state ships as\n        # a separate StateType.C128_STATE component and must not be counted\n        # here.\n        swa_L = len(dst_kv_ptrs) - 2 * c4_full\n        if swa_L < 0 or swa_L > len(mla_ratios):\n            raise ValueError(\n                f\"Unexpected compressed-MLA dst_kv_ptrs length \"\n                f\"{len(dst_kv_ptrs)}; expected either {kv_layout_len} \"\n                f\"(kv_data) or swa_L + {2 * c4_full} \"\n                f\"(state_data) given compression_ratios \"\n                f\"(c4={c4_full}, c128={c128_full}, \"\n                f\"total={len(mla_ratios)}).\"\n            )\n\n        swa_s = min(start_layer, swa_L)\n        swa_e = min(end_layer, swa_L)\n        compress_section_start = swa_L\n        indexer_section_start = swa_L + c4_full\n        sliced_dst = (\n            list(dst_kv_ptrs[swa_s:swa_e])\n            + list(\n                dst_kv_ptrs[\n                    compress_section_start\n                    + c4_off_s : compress_section_start","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/disaggregation/common/conn.py#L1014-L1050","documentation":"Raised by _mla_slice_ptrs_for_pp when slicing destination KV pointers for pipeline-parallel transfer of compressed-MLA data. It infers whether dst_kv_ptrs is a kv_data list (expected length kv_layout_len) or a state_data list (swa_L + 2*c4_full); if the length fits neither interpretation given the model's compression_ratios, the pointer layout is unrecognized.","triggerScenarios":"Calling get_mla_kv_ptrs_with_pp / _mla_slice_ptrs_for_pp where dst_kv_ptrs length < 2*c4_full or exceeds len(mla_ratios) + 2*c4_full, e.g. a transfer backend returning wrong number of destination buffers for compressed MLA (DSA/SWA) pools.","commonSituations":"A new or updated MLA model with unusual compression_ratios (c4/c128 layout) that the slicer doesn't account for; a custom transfer backend building the dst pointer list with missing or extra buffers; nextn/SWA padding edge cases.","solutions":["Check that the transfer backend's destination allocation for compressed-MLA produces exactly one pointer per entry in compression_ratios (state) or matches kv_layout_len (data)","Log len(dst_kv_ptrs), c4_full, c128_full and len(mla_ratios) at the call site to identify which layout was intended, then fix the allocator accordingly","If model support is the issue, verify compression_ratios for your model are in the expected order/format"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"expected_state = swa_L + 2 * c4_full\nassert len(dst_kv_ptrs) in (kv_layout_len, expected_state)","typeGuard":null,"tryCatchPattern":"try:\n    ptrs = _mla_slice_ptrs_for_pp(...)\nexcept ValueError as e:\n    logger.error('dst ptr layout unrecognized: %s', e)\n    raise","preventionTips":["Backend tests should assert dst pointer counts match compression_ratios","Log compression_ratios alongside pointer counts when integrating new MLA models"],"tags":["disaggregation","mla","pipeline-parallel","kv-pointers","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}