{"record":{"id":"77557254c9185425","repo":"sgl-project/sglang","slug":"unsupported-layout-self-layout-775572","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/dsa.py","lineNumber":178,"sourceCode":"                [x.data_ptr() for x in self.index_k_data_refs],\n                dtype=torch.uint64,\n                device=self.device_pool.device,\n            )\n        elif self.layout in [\"page_first\", \"page_first_direct\"]:\n            self.index_k_with_scale_buffer = alloc_func(\n                (\n                    self.indexer_page_num,\n                    self.layer_num,\n                    1,\n                    self.indexer_page_stride_size,\n                ),\n                dtype=self.indexer_dtype,\n                device=self.device,\n                pin_memory=self.pin_memory,\n                allocator=self.allocator,\n            )\n        else:\n            raise ValueError(f\"Unsupported layout: {self.layout}\")\n\n    def _init_write_back_staging_buffers(self):\n        self.staging_buffer = None\n        if self.layout != \"page_first\" or (_is_npu or _is_xpu or _is_mps):\n            return\n\n        self.can_use_write_back_jit = _is_cuda and can_use_write_back_jit_kernel(\n            element_size=self.indexer_page_stride_size * self.indexer_dtype.itemsize,\n        )\n        staging_page_capacity = min(\n            self.indexer_page_num, _WRITE_BACK_STAGING_PAGE_CHUNK\n        )\n        self.staging_buffer = torch.empty(\n            (\n                staging_page_capacity,\n                self.layer_num,\n                1,\n                self.indexer_page_stride_size,","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/pool_host/dsa.py#L160-L196","documentation":"The host DSA indexer pool allocates its index buffer with one of two memory layouts, 'layer_first' or 'page_first'. init_kv_buffer raises this when self.layout is neither. It is a configuration/state error, not runtime data dependent.","triggerScenarios":"Passing a layout string other than 'layer_first' or 'page_first' (typo, wrong case, or a new unsupported value) to the DSA host pool constructor.","commonSituations":"Typos in config, case mismatch ('LayerFirst'), or code written against a fork that added a layout not present in this version.","solutions":["Set layout to exactly 'layer_first' or 'page_first'","Check where the layout string originates (server args / config) and correct it","Note page_first has extra restrictions (see staging buffer, NPU/XPU/MPS exclusion)"],"exampleFix":"# before\nlayout=\"layers_first\"\n# after\nlayout=\"layer_first\"","handlingStrategy":"type-guard","validationCode":"assert layout in (\"layer_first\", \"page_first\"), layout","typeGuard":"def is_valid_dsa_layout(l: str) -> bool:\n    return l in (\"layer_first\", \"page_first\")","tryCatchPattern":null,"preventionTips":["Validate layout at config load time, not deep in the pool"],"tags":["config","dsa-hicache","layout"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}