sgl-project/sglang · error · ValueError

hidden size is outside the supported LTX2 fast-path range

Error message

hidden size is outside the supported LTX2 fast-path range

What it means

The LTX2 fast-path Triton kernel only supports hidden sizes that are multiples of 256 up to 8192 (kernel block-size constraints). Hidden sizes outside this range raise this error instead of launching the kernel.

Source

Thrown at python/sglang/kernels/ops/diffusion/modulate/ltx2_ada_values_triton.py:164

    if not timestep.is_contiguous():
        raise ValueError("timestep must be contiguous")
    if scale_shift_table.ndim != 2 or scale_shift_table.shape[0] != 9:
        raise ValueError("scale_shift_table must have shape [9, D]")
    if (
        not scale_shift_table.is_cuda
        or scale_shift_table.dtype not in (torch.bfloat16, torch.float32)
        or scale_shift_table.stride(-1) != 1
    ):
        raise ValueError(
            "scale_shift_table must be CUDA, bf16/fp32, last-dim contiguous"
        )

    total_params = int(scale_shift_table.shape[0])
    hidden = int(scale_shift_table.shape[1])
    if hidden <= 0 or timestep.shape[-1] != total_params * hidden:
        raise ValueError("timestep last dim must equal 9 * hidden")
    if hidden % 256 != 0 or hidden > 8192:
        raise ValueError("hidden size is outside the supported LTX2 fast-path range")

    batch, seq, _ = timestep.shape
    rows = int(batch * seq)
    # Each returned output is a disjoint, contiguous view, so one allocation
    # avoids nine allocator round trips per transformer block.
    output_storage = torch.empty(
        (9, batch, seq, hidden), device=timestep.device, dtype=timestep.dtype
    )
    outs = tuple(output_storage.unbind(dim=0))
    _ltx2_ada_values9_kernel[(rows,)](
        timestep,
        scale_shift_table,
        *outs,
        rows,
        hidden,
        total_params,
        scale_shift_table.stride(0),
        scale_shift_table.stride(1),

View on GitHub (pinned to 0132848349)

Solutions

  1. Pad or choose a hidden size that is a multiple of 256 and <= 8192
  2. Fall back to the non-fused reference AdaLN computation for unsupported hidden sizes (the _ltx2_try_fused_ada_values9 caller should catch this and use eager)
  3. Extend the kernel's block-size handling if a genuinely new range is needed

Example fix

# before
vals = ltx2_ada_values9(table_d1280, t)  # raises
# after
try:
    vals = ltx2_ada_values9(table, t)
except ValueError:
    vals = reference_ltx2_ada_values9(table, t)
Defensive patterns

Strategy: fallback

Validate before calling

hidden = scale_shift_table.shape[1]
fused_ok = hidden % 256 == 0 and hidden <= 8192

Type guard

def hidden_supported(table: torch.Tensor) -> bool:
    h = table.shape[1]
    return h % 256 == 0 and h <= 8192

Try / catch

try:
    vals = ltx2_ada_values9(table, timestep)
except ValueError:
    vals = reference_ltx2_ada_values9(table, timestep)

Prevention

When it happens

Trigger: Calling ltx2_ada_values9 with a scale_shift_table whose hidden dim D is not a multiple of 256 (e.g. 1536 is fine, 1280 or 1000 is not) or larger than 8192.

Common situations: Custom LTX2 variants with unusual hidden dims; resized checkpoints; hidden sizes from other DiT architectures being routed into the LTX2 fused path.

Related errors


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