{"record":{"id":"ad244d2815aec4f3","repo":"sgl-project/sglang","slug":"a-log-dt-bias-must-be-contiguous","errorCode":null,"errorMessage":"`A_log`/`dt_bias` must be contiguous.","messagePattern":"`A_log`/`dt_bias` must be contiguous\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/fla/fused_recurrent.py","lineNumber":295,"sourceCode":"    ssm_state_indices: torch.Tensor,\n    use_qk_l2norm_in_kernel: bool = False,\n) -> tuple[torch.Tensor, torch.Tensor]:\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            f\"`ssm_state_indices` must be 1D for packed decode (got ndim={ssm_state_indices.ndim}).\"\n        )\n    if not out.is_contiguous():\n        raise ValueError(\"`out` must be contiguous.\")\n\n    dev = mixed_qkv.device\n    if any(\n        t.device != dev\n        for t in (a, b, A_log, dt_bias, initial_state, out, ssm_state_indices)\n    ):\n        raise ValueError(\"All inputs must be on the same device.\")\n\n    B = mixed_qkv.shape[0]\n    if a.shape[0] != B or b.shape[0] != B:\n        raise ValueError(\n            \"Mismatched batch sizes: \"","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/fla/fused_recurrent.py#L277-L313","documentation":"Same contiguity contract as the other inputs: the 1D A_log and dt_bias vectors must have stride(0) == 1. The wrapper raises when either parameter is a strided view, e.g. a column/row slice of a 2D parameter or a sub-selection of heads with gaps.","triggerScenarios":"A_log = w[:, 0] on a (HV, 2) buffer (stride 2), selecting heads via an index tensor leaving non-unit stride, or params loaded as transposed views without materialization.","commonSituations":"Weight sharding across tensor-parallel ranks where A_log is sliced from a larger per-head buffer; fused parameter storage that packs A_log with other params; passing A_log.t() of a stored row.","solutions":["Materialize compact copies: A_log = A_log.contiguous(); dt_bias = dt_bias.contiguous()","Store A_log/dt_bias as separate flat parameters per rank instead of slicing packed buffers"],"exampleFix":"# before\nA_log = fused_param[:, 0]  # stride 2\n# after\nA_log = fused_param[:, 0].contiguous()","handlingStrategy":"validation","validationCode":"A_log = A_log.contiguous() if A_log.stride(0) != 1 else A_log\ndt_bias = dt_bias.contiguous() if dt_bias.stride(0) != 1 else dt_bias","typeGuard":"def vec_contiguous(t: torch.Tensor) -> bool:\n    return t.ndim == 1 and t.stride(0) == 1","tryCatchPattern":null,"preventionTips":["Never pass column slices of packed parameter buffers directly; copy them out","After TP sharding, materialize per-rank parameter copies with .contiguous()"],"tags":["fla","fused-recurrent","contiguity","mamba-params"],"backgroundTag":"tensor-not-contiguous","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}