sgl-project/sglang · error · ValueError

`A_log`/`dt_bias` must be contiguous.

Error message

`A_log`/`dt_bias` must be contiguous.

What it means

A_log and dt_bias must have stride(0)==1, i.e. be contiguous 1D vectors; strided views would cause incorrect indexing in the Triton kernel, so the validator rejects them upfront.

Source

Thrown at python/sglang/kernels/ops/attention/helion/kda_decode.py:243

    ssm_state_indices: torch.Tensor,
) -> tuple[int, int, int, int, int]:
    """Apply the shape and layout checks from SGLang's packed wrapper."""
    if mixed_qkv.ndim != 2:
        raise ValueError(
            f"`mixed_qkv` must be a 2D tensor (got ndim={mixed_qkv.ndim})."
        )
    if mixed_qkv.stride(-1) != 1:
        raise ValueError("`mixed_qkv` must be contiguous in the last dim.")
    if a.ndim != 2 or b.ndim != 2:
        raise ValueError(
            f"`a` and `b` must be 2D tensors (got a.ndim={a.ndim}, b.ndim={b.ndim})."
        )
    if a.stride(-1) != 1 or b.stride(-1) != 1:
        raise ValueError("`a`/`b` must be contiguous in the last dim.")
    if A_log.ndim != 1 or dt_bias.ndim != 1:
        raise ValueError("`A_log`/`dt_bias` must be 1D tensors.")
    if A_log.stride(0) != 1 or dt_bias.stride(0) != 1:
        raise ValueError("`A_log`/`dt_bias` must be contiguous.")
    if ssm_state_indices.ndim != 1:
        raise ValueError(
            "`ssm_state_indices` must be 1D for packed decode "
            f"(got ndim={ssm_state_indices.ndim})."
        )
    if not out.is_contiguous():
        raise ValueError("`out` must be contiguous.")

    device = mixed_qkv.device
    if any(
        tensor.device != device
        for tensor in (
            a,
            b,
            A_log,
            dt_bias,
            initial_state,
            out,

View on GitHub (pinned to 0132848349)

Solutions

  1. Call .contiguous() on A_log and dt_bias
  2. Load/copy parameters into contiguous buffers

Example fix

# before
out = decode(qkv, a, b, A_log_slice, dt_bias_slice, ...)  # strided
# after
out = decode(qkv, a, b, A_log_slice.contiguous(), dt_bias_slice.contiguous(), ...)
Defensive patterns

Strategy: validation

Validate before calling

A_log = A_log.contiguous()
dt_bias = dt_bias.contiguous()

Prevention

When it happens

Trigger: Passing A_log or dt_bias as a non-contiguous slice (e.g. A_log[::2] or a column of a 2D param).

Common situations: Sub-selecting dims of a fused parameter buffer; quantized/dequantized parameter views.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/68620b4c26cea749. Report an issue: GitHub.