{"record":{"id":"99348e515f77df70","repo":"sgl-project/sglang","slug":"staging-is-enabled-but-kv-manager-staging-ctx-all","errorCode":null,"errorMessage":"Staging is enabled but kv_manager._staging_ctx.allocator is None. Check that the transfer backend correctly initializes the staging allocator.","messagePattern":"Staging is enabled but kv_manager\\._staging_ctx\\.allocator is None\\. Check that the transfer backend correctly initializes the staging allocator\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/disaggregation/common/staging_handler.py","lineNumber":129,"sourceCode":"            self._wm_subscribers[key] = (receiver, session_id)\n\n    def num_writers_for(self, receiver) -> int:\n        \"\"\"Compute all TP and PP writers expected for a staging chunk.\"\"\"\n        prefill_info = receiver.prefill_info\n        prefill_tp = prefill_info.attn_tp_size\n        if prefill_tp > self.decode_tp:\n            tp_writers = prefill_tp // max(1, self.decode_tp)\n        else:\n            tp_writers = 1\n        pp_writers = prefill_info.pp_size // self.kv_manager.pp_size\n        return tp_writers * pp_writers\n\n    @classmethod\n    def create(cls, kv_manager, scheduler, tp_rank: int) -> DecodeStagingHandler:\n        \"\"\"Factory: create handler. Raises if staging infra is missing.\"\"\"\n        staging_allocator = kv_manager._staging_ctx.allocator\n        if staging_allocator is None:\n            raise RuntimeError(\n                \"Staging is enabled but kv_manager._staging_ctx.allocator is None. \"\n                \"Check that the transfer backend correctly initializes the staging allocator.\"\n            )\n        kv_buffer_info = kv_manager.kv_buffer_tensors\n        if kv_buffer_info is None:\n            raise RuntimeError(\n                \"Staging is enabled but kv_manager.kv_buffer_tensors is None. \"\n                \"Check that set_kv_buffer_tensors() was called during kv_manager init.\"\n            )\n        decode_tp = kv_manager.attn_tp_size\n\n        from sglang.srt.disaggregation.common.staging_buffer import (\n            resolve_total_kv_heads,\n        )\n\n        total_kv_heads = resolve_total_kv_heads(kv_manager.kv_args, decode_tp)\n        return cls(\n            kv_manager=kv_manager,","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/disaggregation/common/staging_handler.py#L111-L147","documentation":"DecodeStagingHandler.create reads kv_manager._staging_ctx.allocator and refuses to construct the handler when the staging allocator is None. The staging-buffer feature (SGLANG_DISAGG_STAGING_BUFFER) requires the active transfer backend to have allocated the staging pool during kv_manager initialization.","triggerScenarios":"Setting SGLANG_DISAGG_STAGING_BUFFER=1 on a decode server whose transfer backend does not (or not yet) initialize _staging_ctx.allocator — e.g. an unsupported backend or initialization-order bug.","commonSituations":"Enabling the staging flag with a backend that never implemented staging; a backend refactor that deferred/removed allocator setup; race where handler creation precedes backend init.","solutions":["Switch to a transfer backend that supports the staging allocator (check backend init code for _staging_ctx.allocator assignment)","Unset SGLANG_DISAGG_STAGING_BUFFER if you don't need staging","If developing a backend, assign kv_manager._staging_ctx.allocator during kv_manager init before transfer_queue._init_staging_handler runs"],"exampleFix":"# before\nexport SGLANG_DISAGG_STAGING_BUFFER=1  # backend without staging support\n# after\nunset SGLANG_DISAGG_STAGING_BUFFER","handlingStrategy":"validation","validationCode":"if envs.SGLANG_DISAGG_STAGING_BUFFER.get():\n    assert kv_manager._staging_ctx.allocator is not None, 'backend lacks staging allocator'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable the staging env var on backends documented to support it","Check backend release notes before toggling experimental env flags"],"tags":["disaggregation","staging-buffer","env-var","allocator","initialization"],"backgroundTag":"feature-not-supported-by-backend","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}