{"record":{"id":"d98687be7afe3d5c","repo":"sgl-project/sglang","slug":"allow-neg-eigval-true-requires-2-sigmoid-beta-wh","errorCode":null,"errorMessage":"allow_neg_eigval=True requires 2*sigmoid(beta), which is not implemented by the fused beta path; pass pre-activated beta with use_beta_sigmoid_in_kernel=False","messagePattern":"allow_neg_eigval=True requires 2\\*sigmoid\\(beta\\), which is not implemented by the fused beta path; pass pre-activated beta with use_beta_sigmoid_in_kernel=False","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/linear/kda_ptx_prefill/__init__.py","lineNumber":119,"sourceCode":"        table -- pass cu_seqlens_cpu to avoid the D2H sync; chunk_indices is\n        accepted and ignored (the kernel derives its own piece table).\n      initial_state [N,H,128,128] fp32 or None (zeros).\n      return_intermediate_states=True returns dense fp32 chunk-boundary states\n        [1, NT, H, 128, 128] at tuple index 10.\n\n    Returns the fla-shaped 12-tuple: (o [B,T,H,128] bf16, final_state\n    [N,H,128,128] fp32 or None, then Nones, ..., h, initial_state).\n    \"\"\"\n    assert (\n        chunk_size == CHUNK\n    ), f\"kda_prefill supports chunk_size={CHUNK} only, got {chunk_size}\"\n    if cp_context is not None or disable_recompute:\n        raise NotImplementedError(\n            \"kda_prefill is the inference forward path: cp_context, \"\n            \"and disable_recompute are training-side knobs it does not implement\"\n        )\n    if allow_neg_eigval and use_beta_sigmoid_in_kernel:\n        raise NotImplementedError(\n            \"allow_neg_eigval=True requires 2*sigmoid(beta), which is not \"\n            \"implemented by the fused beta path; pass pre-activated beta with \"\n            \"use_beta_sigmoid_in_kernel=False\"\n        )\n    if state_v_first and initial_state is not None:\n        # [V,K]-layout state: pure transpose (K==V==128), exact, ~us/call\n        initial_state = initial_state.transpose(-1, -2).contiguous()\n    assert (\n        q.dim() == 4 and q.shape[-1] == K and v.shape[-1] == K\n    ), f\"expected [B,T,H,{K}] q/k/v, got q={tuple(q.shape)} v={tuple(v.shape)}\"\n    B, T, H, _ = q.shape\n\n    cu_cpu = None\n    if cu_seqlens is not None or cu_seqlens_cpu is not None:\n        assert B == 1, \"cu_seqlens requires B == 1 (flattened varlen batch)\"\n        src = cu_seqlens_cpu if cu_seqlens_cpu is not None else cu_seqlens\n        cu_cpu = torch.as_tensor(src, dtype=torch.int32).cpu()\n    elif B > 1:","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/linear/kda_ptx_prefill/__init__.py#L101-L137","documentation":"The fused beta path computes sigmoid(beta) inside the kernel, which forces beta >= 0 semantics. allow_neg_eigval=True needs the 2*sigmoid(beta) parameterization which that fused path does not implement, so the combination is rejected.","triggerScenarios":"Calling kda_prefill with allow_neg_eigval=True and use_beta_sigmoid_in_kernel=True (the default fused beta activation).","commonSituations":"Loading a KDA checkpoint trained with negative eigenvalues (allow_neg_eigval=True) while keeping the kernel-side sigmoid default; upgrading configs where beta is now expected pre-activated.","solutions":["Pre-activate beta yourself (beta = 2*sigmoid(beta_raw)) and pass use_beta_sigmoid_in_kernel=False","If you do not need negative eigenvalues, set allow_neg_eigval=False"],"exampleFix":"// before\nkda_prefill(q, k, v, beta=beta_raw, allow_neg_eigval=True, use_beta_sigmoid_in_kernel=True)\n// after\nbeta = torch.sigmoid(beta_raw) * 2  # pre-activated\nkda_prefill(q, k, v, beta=beta, allow_neg_eigval=True, use_beta_sigmoid_in_kernel=False)","handlingStrategy":"validation","validationCode":"if allow_neg_eigval:\n    beta = torch.sigmoid(beta) * 2\n    use_beta_sigmoid_in_kernel = False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide beta activation ownership (caller vs kernel) once at model init","Check allow_neg_eigval × use_beta_sigmoid_in_kernel compatibility in config validation"],"tags":["kda","beta","flag-conflict","not-implemented"],"backgroundTag":"incompatible-flag-combination","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}