{"record":{"id":"141ed49f47627541","repo":"sgl-project/sglang","slug":"a-log-dt-bias-must-be-1d-tensors-141ed4","errorCode":null,"errorMessage":"`A_log`/`dt_bias` must be 1D tensors.","messagePattern":"`A_log`/`dt_bias` must be 1D tensors\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/helion/kda_decode.py","lineNumber":241,"sourceCode":"    initial_state: torch.Tensor,\n    out: torch.Tensor,\n    ssm_state_indices: torch.Tensor,\n) -> tuple[int, int, int, int, int]:\n    \"\"\"Apply the shape and layout checks from SGLang's packed wrapper.\"\"\"\n    if mixed_qkv.ndim != 2:\n        raise ValueError(\n            f\"`mixed_qkv` must be a 2D tensor (got ndim={mixed_qkv.ndim}).\"\n        )\n    if mixed_qkv.stride(-1) != 1:\n        raise ValueError(\"`mixed_qkv` must be contiguous in the last dim.\")\n    if a.ndim != 2 or b.ndim != 2:\n        raise ValueError(\n            f\"`a` and `b` must be 2D tensors (got a.ndim={a.ndim}, b.ndim={b.ndim}).\"\n        )\n    if a.stride(-1) != 1 or b.stride(-1) != 1:\n        raise ValueError(\"`a`/`b` must be contiguous in the last dim.\")\n    if A_log.ndim != 1 or dt_bias.ndim != 1:\n        raise ValueError(\"`A_log`/`dt_bias` must be 1D tensors.\")\n    if A_log.stride(0) != 1 or dt_bias.stride(0) != 1:\n        raise ValueError(\"`A_log`/`dt_bias` must be contiguous.\")\n    if ssm_state_indices.ndim != 1:\n        raise ValueError(\n            \"`ssm_state_indices` must be 1D for packed decode \"\n            f\"(got ndim={ssm_state_indices.ndim}).\"\n        )\n    if not out.is_contiguous():\n        raise ValueError(\"`out` must be contiguous.\")\n\n    device = mixed_qkv.device\n    if any(\n        tensor.device != device\n        for tensor in (\n            a,\n            b,\n            A_log,\n            dt_bias,","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/helion/kda_decode.py#L223-L259","documentation":"A_log and dt_bias are per-channel parameter vectors of shape [dim]; the kernel indexes them linearly, so they must be 1D. Higher-rank tensors (e.g. [1, dim] or [heads, d]) are rejected.","triggerScenarios":"Calling packed decode with A_log or dt_bias whose ndim != 1.","commonSituations":"Parameters loaded with an extra leading dim or reshaped for a multi-head convention somewhere else in the model.","solutions":["Reshape A_log/dt_bias with .squeeze()/.view(-1) to 1D","Check model weights preprocessing that materializes these params"],"exampleFix":"# before\nout = decode(qkv, a, b, A_log[None, :], dt_bias, ...)\n# after\nout = decode(qkv, a, b, A_log.view(-1), dt_bias.view(-1), ...)","handlingStrategy":"validation","validationCode":"A_log = A_log.view(-1)\ndt_bias = dt_bias.view(-1)\nassert A_log.ndim == 1 and dt_bias.ndim == 1","typeGuard":"def is_1d(t: torch.Tensor) -> bool:\n    return t.ndim == 1","tryCatchPattern":null,"preventionTips":["Normalize parameter shapes once at weight load time","Add weight-shape checks in model loading code"],"tags":["kda","mamba","tensor-shape","parameters","helion"],"backgroundTag":"invalid-tensor-shape","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}