{"record":{"id":"dbac951663854433","repo":"sgl-project/sglang","slug":"topk-kernels-only-support-streaming-implementation","errorCode":null,"errorMessage":"topk kernels only support streaming implementation: {_impl=}","messagePattern":"topk kernels only support streaming implementation: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/moe/gate_topk.py","lineNumber":163,"sourceCode":"        BLOCK_SIZE_N = 32\n        BLOCK_SIZE_M = 32\n        grid = (triton.cdiv(n_rows, BLOCK_SIZE_M),)\n        _streaming_topk_kernel[grid](\n            x_ptr=x,\n            stride_xm=x.stride(0),\n            values_ptr=values,\n            indices_ptr=indices,\n            M=n_rows,\n            N=n_cols,\n            N_PAD=triton.cdiv(n_cols, BLOCK_SIZE_N) * BLOCK_SIZE_N,\n            K=k,\n            K_POW2=triton.next_power_of_2(k),\n            BLOCK_SIZE_M=BLOCK_SIZE_M,\n            BLOCK_SIZE_N=BLOCK_SIZE_N,\n            RETURN_VALUES=return_values,\n        )\n    else:\n        raise NotImplementedError(\n            f\"topk kernels only support streaming implementation: {_impl=}\"\n        )\n\n    if return_values:\n        return values, indices\n    return indices\n","sourceCodeStart":145,"sourceCodeEnd":170,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/moe/gate_topk.py#L145-L170","documentation":"NotImplementedError from gate_topk: only _impl == \"streaming\" has a code path. Any other value for the internal _impl selector falls into the else branch and raises, because no alternative kernel implementation is compiled in this build.","triggerScenarios":"Calling gate_topk with _impl set to something other than \"streaming\" (e.g. \"naive\", \"sorted\", or an experimental name) from the routing forward.","commonSituations":"Adding a new topk implementation flag without wiring a kernel; copy-pasted code passing an outdated impl name; feature-flag plumbing that defaults to an unimplemented variant.","solutions":["Pass _impl=\"streaming\" or rely on the default","If you intended a new implementation, implement the branch in gate_topk before enabling the flag","Remove the impl parameter from the call if the streaming path is fine"],"exampleFix":"// before\nids = gate_topk(x, k=8, _impl=\"naive\")\n// after\nids = gate_topk(x, k=8)  # defaults to the streaming implementation","handlingStrategy":"validation","validationCode":"assert _impl in (\"streaming\", None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't expose impl flags without an implementation","Keep a registry of valid _impl values"],"tags":["moe","topk","not-implemented","feature-flag"],"backgroundTag":"unsupported-implementation-flag","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}