sgl-project/sglang · error · ValueError

`A_log`/`dt_bias` must be 1D tensors.

Error message

`A_log`/`dt_bias` must be 1D tensors.

What it means

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.

Source

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

    initial_state: torch.Tensor,
    out: torch.Tensor,
    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,

View on GitHub (pinned to 0132848349)

Solutions

  1. Reshape A_log/dt_bias with .squeeze()/.view(-1) to 1D
  2. Check model weights preprocessing that materializes these params

Example fix

# before
out = decode(qkv, a, b, A_log[None, :], dt_bias, ...)
# after
out = decode(qkv, a, b, A_log.view(-1), dt_bias.view(-1), ...)
Defensive patterns

Strategy: validation

Validate before calling

A_log = A_log.view(-1)
dt_bias = dt_bias.view(-1)
assert A_log.ndim == 1 and dt_bias.ndim == 1

Type guard

def is_1d(t: torch.Tensor) -> bool:
    return t.ndim == 1

Prevention

When it happens

Trigger: Calling packed decode with A_log or dt_bias whose ndim != 1.

Common situations: Parameters loaded with an extra leading dim or reshaped for a multi-head convention somewhere else in the model.

Related errors


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