sgl-project/sglang · error · ValueError
scale_shift_table must have shape [9, D]
Error message
scale_shift_table must have shape [9, D]
What it means
Shape contract for scale_shift_table in the LTX2 AdaLN values kernel: exactly [9, D] — nine modulation rows over the hidden dimension D. Wrong table shapes mean the checkpoint's modulation head layout doesn't match LTX2's six-signal layout.
Solutions
- Verify scale_shift_table.shape == (9, hidden_dim) before calling
- Load the correct LTX2 checkpoint parameter; transpose if the checkpoint stores [D, 9]
- If porting a 6-param AdaLN model, use the appropriate kernel, not ltx2_ada_values9
Example fix
# before vals = ltx2_ada_values9(table_6row, t) # after assert table.shape[0] == 9 vals = ltx2_ada_values9(table, t)
Defensive patterns
Strategy: validation
Validate before calling
assert scale_shift_table.ndim == 2 and scale_shift_table.shape[0] == 9
Type guard
def table_ok(t: torch.Tensor) -> bool:
return t.dim() == 2 and t.shape[0] == 9 Prevention
- Validate checkpoint params against expected [9, D] at load time
- Don't reuse non-LTX2 AdaLN tables
When it happens
Trigger: Passing a table with 6 rows (standard 6-parameter AdaLN instead of LTX2's 9-parameter variant), a transposed [D, 9] table, or a 1D/3D tensor.
Common situations: Reusing scale_shift_table from a non-LTX2 model (e.g. DiT with shift/scale/gate only); loading a checkpoint whose table layout is transposed; passing the wrong model parameter.
Understand the failure class
Background: Tensor shape mismatch errors ("must have shape", "expected shape ... got ..."): when tensor dimensions disagree with what an op or layer was told to expect — this error's family across 6 libraries.
Related errors
- timestep last dim must equal 9 * hidden
- timestep must have shape [B, S, 9 * D]
- MiniMax H3 AdaLN cache is only compatible with unquantized…
- MiniMax H3 pruned curve checkpoints cannot use a separate…
- --model-variant requires ' ' in the checkpoint, but does…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/2b372a17ec87beac.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/kernels/ops/diffusion/modulate/ltx2_ada_values_triton.py:149
tl.store(out4_ptr + base, (table4 + temb4).to(tl.bfloat16), mask=mask)
tl.store(out5_ptr + base, (table5 + temb5).to(tl.bfloat16), mask=mask)
tl.store(out6_ptr + base, (table6 + temb6).to(tl.bfloat16), mask=mask)
tl.store(out7_ptr + base, (table7 + temb7).to(tl.bfloat16), mask=mask)
tl.store(out8_ptr + base, (table8 + temb8).to(tl.bfloat16), mask=mask)
def ltx2_ada_values9(
scale_shift_table: torch.Tensor,
timestep: torch.Tensor,
) -> tuple[torch.Tensor, ...]:
if timestep.ndim != 3:
raise ValueError("timestep must have shape [B, S, 9 * D]")
if not timestep.is_cuda or timestep.dtype != torch.bfloat16:
raise ValueError("timestep must be a CUDA bfloat16 tensor")
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)View on GitHub (pinned to 0132848349)