{"record":{"id":"c6577f44c51a58e8","repo":"sgl-project/sglang","slug":"unsupported-layout-self-layout-c6577f","errorCode":null,"errorMessage":"Unsupported layout: {self.layout}","messagePattern":"Unsupported layout: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/pool_host/mla.py","lineNumber":198,"sourceCode":"                dtype=self.dtype,\n                device=self.device,\n                pin_memory=self.pin_memory,\n                allocator=self.allocator,\n            )\n            self.index_k_buffer = None\n            if self.device_pool.index_head_dim is not None:\n                self.index_k_buffer = alloc_func(\n                    (*base_dims, self.device_pool.index_head_dim),\n                    dtype=self.dtype,\n                    device=self.device,\n                    pin_memory=self.pin_memory,\n                    allocator=self.allocator,\n                )\n            # Return k_buffer to preserve original kv_buffer and data_refs init logic,\n            # though Ascend doesn't use these parameters.\n            return self.k_buffer\n        else:\n            raise ValueError(f\"Unsupported layout: {self.layout}\")\n        self.token_stride_size = self.kv_cache_dim * self.dtype.itemsize\n        self.layout_dim = self.token_stride_size * self.layer_num\n\n        alloc_func = ALLOC_MEMORY_FUNCS[self.device_pool.device]\n        buffer = alloc_func(\n            dims,\n            dtype=self.dtype,\n            device=self.device,\n            pin_memory=self.pin_memory,\n            allocator=self.allocator,\n        )\n        return buffer\n\n    def _init_write_back_staging_buffers(self):\n        self.staging_page_capacity = 0\n        self.staging_token_capacity = 0\n        self.staging_buffer = None\n        self.can_use_write_back_jit = False","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/pool_host/mla.py#L180-L216","documentation":"The MLA host KV pool's init_kv_buffer hit a layout branch it does not recognize, so it cannot allocate the host kv_buffer. Supported MLA layouts include 'layer_first', 'page_first', 'page_first_kv_split', and the Ascend special case; anything else raises this ValueError.","triggerScenarios":"Constructing the MLA host pool with a layout string outside the supported set (typo like 'layer-first' or a new/renamed layout value).","commonSituations":"Renaming or introducing layouts without updating this branch; passing a custom layout from server args; version mismatch where the caller uses a layout name that this build does not know.","solutions":["Check the value passed for layout and correct it to a supported name ('layer_first', 'page_first', 'page_first_kv_split')","Update sglang so caller and pool agree on layout names","Add an upfront validation/enum for layout values before pool construction"],"exampleFix":"// before\nMLATokenToKVPoolHost(..., layout=\"layer-first\")\n\n// after\nMLATokenToKVPoolHost(..., layout=\"layer_first\")","handlingStrategy":"validation","validationCode":"MLA_HOST_LAYOUTS = {\"layer_first\", \"page_first\", \"page_first_kv_split\"}\nif layout not in MLA_HOST_LAYOUTS:\n    raise ConfigError(f\"layout must be one of {MLA_HOST_LAYOUTS}, got {layout!r}\")","typeGuard":"def is_valid_mla_layout(layout: str) -> bool:\n    return layout in {\"layer_first\", \"page_first\", \"page_first_kv_split\"}","tryCatchPattern":"try:\n    pool = MLATokenToKVPoolHost(..., layout=layout)\nexcept ValueError as e:\n    if \"Unsupported layout\" in str(e):\n        layout = \"layer_first\"  # safe default\n        pool = MLATokenToKVPoolHost(..., layout=layout)\n    else:\n        raise","preventionTips":["Validate layout strings against the pool's supported set before construction","Keep layout constants shared between caller and pool module"],"tags":["sglang","mla","hicache","layout","init"],"backgroundTag":"invalid-configuration-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}