{"record":{"id":"1b62834ea4ac050c","repo":"sgl-project/sglang","slug":"move-kv-cache-is-not-yet-supported-for-minimaxspar","errorCode":null,"errorMessage":"move_kv_cache is not yet supported for MiniMaxSparseKVPool: sub-pools must be built with enable_kv_cache_copy=True first.","messagePattern":"move_kv_cache is not yet supported for MiniMaxSparseKVPool: sub-pools must be built with enable_kv_cache_copy=True first\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/memory_pool.py","lineNumber":5164,"sourceCode":"        return self.main_pool.get_contiguous_buf_infos()\n\n    def get_index_k_state_buf_infos(self):\n        # Per-page item_len (MHATokenToKVPool convention); index rows share the\n        # main-KV `loc`, so the transfer reuses the same page-ids.\n        pool = self.index_k_pool\n        n = pool.layer_num\n        data_ptrs = [pool.k_buffer[i].data_ptr() for i in range(n)]\n        data_lens = [pool.k_buffer[i].nbytes for i in range(n)]\n        item_lens = [pool.k_buffer[i][0].nbytes * pool.page_size for i in range(n)]\n        return data_ptrs, data_lens, item_lens\n\n    def maybe_get_custom_mem_pool(self):\n        return self.main_pool.maybe_get_custom_mem_pool()\n\n    def move_kv_cache(self, tgt_loc: torch.Tensor, src_loc: torch.Tensor):\n        # TODO: spec-decode needs sub-pools built with enable_kv_cache_copy=True,\n        # then delegate to main_pool/index_pool.move_kv_cache.\n        raise NotImplementedError(\n            \"move_kv_cache is not yet supported for MiniMaxSparseKVPool: \"\n            \"sub-pools must be built with enable_kv_cache_copy=True first.\"\n        )\n\n    def get_v_head_dim(self):\n        # Use start_layer to handle pipeline parallelism where layer 0\n        # may not be present in this stage's buffer.\n        return self.main_pool.get_value_buffer(self.main_pool.start_layer).shape[-1]\n","sourceCodeStart":5146,"sourceCodeEnd":5173,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/memory_pool.py#L5146-L5173","documentation":"MiniMaxSparseKVPool (a wrapper around per-layer sub-pools for the MiniMax sparse attention model) does not implement move_kv_cache. The method unconditionally raises NotImplementedError because moving KV cache locations requires the sub-pools to be constructed with enable_kv_cache_copy=True so their tensors can be reindexed/copied safely.","triggerScenarios":"Calling move_kv_cache(tgt_loc, src_loc) on a MiniMaxSparseKVPool instance — typically triggered by SGLang's speculative decoding (e.g. EAGLE-style draft/verify) or hierarchical cache offload/eviction paths that relocate KV entries after a batch runs.","commonSituations":"Running the MiniMax-M1/MiniMax sparse model together with --speculative-algorithm or hierarchical cache features; hitting the TODO in the source before sub-pool support for KV copy was added.","solutions":["Disable speculative decoding (remove --speculative-algorithm) when serving MiniMaxSparseKVPool models","Avoid/disable features that call move_kv_cache (e.g. certain HiCache/offload eviction strategies) for this model","If you control pool construction, build the sub-pools with enable_kv_cache_copy=True and implement delegation to main_pool/index_pool.move_kv_cache as the TODO describes, then upstream the patch","Follow the SGLang repo/issue tracker for MiniMax sparse + spec-decode support status before upgrading"],"exampleFix":"# before\npool.move_kv_cache(tgt_loc, src_loc)  # NotImplementedError\n\n# after (caller guard)\nif isinstance(pool, MiniMaxSparseKVPool):\n    raise RuntimeError(\"spec-decode not supported for MiniMaxSparseKVPool; disable it\")\npool.move_kv_cache(tgt_loc, src_loc)","handlingStrategy":"type-guard","validationCode":"from sglang.srt.mem_cache.memory_pool import MiniMaxSparseKVPool\nif isinstance(pool, MiniMaxSparseKVPool):\n    raise RuntimeError(\"move_kv_cache unsupported for MiniMaxSparseKVPool\")","typeGuard":"def supports_move_kv_cache(pool) -> bool:\n    return not isinstance(pool, MiniMaxSparseKVPool)","tryCatchPattern":"try:\n    pool.move_kv_cache(tgt, src)\nexcept NotImplementedError as e:\n    logger.warning(\"KV move unsupported (%s); disabling spec-decode path\", e)\n    self.spec_algorithm = None","preventionTips":["Don't enable --speculative-algorithm with MiniMax sparse models","Check the pool class before wiring features that relocate KV entries","Track upstream support status for MiniMaxSparseKVPool sub-pool KV copy"],"tags":["sglang","kv-cache","not-implemented","speculative-decoding","minimax"],"backgroundTag":"unsupported-feature-not-implemented","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}