{"record":{"id":"df82333f2e1f4dc8","repo":"sgl-project/sglang","slug":"ptxkdakernel-is-prefill-only","errorCode":null,"errorMessage":"PtxKDAKernel is prefill-only","messagePattern":"PtxKDAKernel is prefill-only","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/attention/linear/kernels/kda_ptx.py","lineNumber":79,"sourceCode":"        self._param_flat = {}\n        self._unsupported_logged = False\n        # (bucket, H, K, V, device) -> staging dict for ragged token counts.\n        self._staging = {}\n\n    def _ensure_loaded(self):\n        if self._fwd is None:\n            from sglang.kernels.ops.attention.linear.kda_ptx_prefill import (\n                chunk_kda_fwd,\n                load_ext,\n            )\n\n            logger.info(\"Building the PTX KDA prefill extension (first use, ~1-2 min)\")\n            load_ext()\n            self._fwd = chunk_kda_fwd\n            logger.info(\"Using PTX KDA chunked prefill (GB300 / sm_103a)\")\n\n    def decode(self, *args, **kwargs):\n        raise NotImplementedError(\"PtxKDAKernel is prefill-only\")\n\n    def target_verify(self, *args, **kwargs):\n        raise NotImplementedError(\"PtxKDAKernel does not support target_verify\")\n\n    def _flat_param(self, t: Optional[torch.Tensor]) -> Optional[torch.Tensor]:\n        if t is None:\n            return None\n        key = (t.data_ptr(), t.dtype, tuple(t.shape))\n        flat = self._param_flat.get(key)\n        if flat is None:\n            flat = t.detach().reshape(-1).float().contiguous()\n            self._param_flat[key] = flat\n        return flat\n\n    def _get_staging(self, bucket, num_heads, head_k_dim, head_v_dim, dev):\n        key = (bucket, num_heads, head_k_dim, head_v_dim, dev.index)\n        st = self._staging.get(key)\n        if st is None:","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/attention/linear/kernels/kda_ptx.py#L61-L97","documentation":"PtxKDAKernel is a GB300/sm_103a PTX chunked prefill kernel; it has no decode kernel and raises NotImplementedError from decode() to keep decode on another backend.","triggerScenarios":"Dispatching decode to PtxKDAKernel — direct call or misrouted backend configuration.","commonSituations":"Running on GB300 with the PTX backend enabled for all phases; dispatcher change that removed the decode fallback.","solutions":["Route decode to a decode-capable KDA kernel (triton/flashinfer/helion)","Use PTX kernel for prefill only","Verify per-phase backend routing config"],"exampleFix":"# before\nkernel = PtxKDAKernel(); out = kernel.decode(...)\n# after\nout = triton_decode_kernel.decode(...)","handlingStrategy":"type-guard","validationCode":"if phase == 'decode':\n    assert not isinstance(kernel, PtxKDAKernel), 'PTX KDA kernel is prefill-only'","typeGuard":"def kernel_supports_decode(kernel) -> bool:\n    return type(kernel).decode.__code__ is not PtxKDAKernel.decode.__code__","tryCatchPattern":null,"preventionTips":["Keep the PTX kernel on the prefill path only","Validate phase routing in config tests for GB300 deployments"],"tags":["sglang","ptx","kda","gb300","decode","not-implemented"],"backgroundTag":"unsupported-operation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}