{"record":{"id":"2b372a17ec87beac","repo":"sgl-project/sglang","slug":"scale-shift-table-must-have-shape-9-d","errorCode":null,"errorMessage":"scale_shift_table must have shape [9, D]","messagePattern":"scale_shift_table must have shape \\[9, D\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/diffusion/modulate/ltx2_ada_values_triton.py","lineNumber":149,"sourceCode":"    tl.store(out4_ptr + base, (table4 + temb4).to(tl.bfloat16), mask=mask)\n    tl.store(out5_ptr + base, (table5 + temb5).to(tl.bfloat16), mask=mask)\n    tl.store(out6_ptr + base, (table6 + temb6).to(tl.bfloat16), mask=mask)\n    tl.store(out7_ptr + base, (table7 + temb7).to(tl.bfloat16), mask=mask)\n    tl.store(out8_ptr + base, (table8 + temb8).to(tl.bfloat16), mask=mask)\n\n\ndef ltx2_ada_values9(\n    scale_shift_table: torch.Tensor,\n    timestep: torch.Tensor,\n) -> tuple[torch.Tensor, ...]:\n    if timestep.ndim != 3:\n        raise ValueError(\"timestep must have shape [B, S, 9 * D]\")\n    if not timestep.is_cuda or timestep.dtype != torch.bfloat16:\n        raise ValueError(\"timestep must be a CUDA bfloat16 tensor\")\n    if not timestep.is_contiguous():\n        raise ValueError(\"timestep must be contiguous\")\n    if scale_shift_table.ndim != 2 or scale_shift_table.shape[0] != 9:\n        raise ValueError(\"scale_shift_table must have shape [9, D]\")\n    if (\n        not scale_shift_table.is_cuda\n        or scale_shift_table.dtype not in (torch.bfloat16, torch.float32)\n        or scale_shift_table.stride(-1) != 1\n    ):\n        raise ValueError(\n            \"scale_shift_table must be CUDA, bf16/fp32, last-dim contiguous\"\n        )\n\n    total_params = int(scale_shift_table.shape[0])\n    hidden = int(scale_shift_table.shape[1])\n    if hidden <= 0 or timestep.shape[-1] != total_params * hidden:\n        raise ValueError(\"timestep last dim must equal 9 * hidden\")\n    if hidden % 256 != 0 or hidden > 8192:\n        raise ValueError(\"hidden size is outside the supported LTX2 fast-path range\")\n\n    batch, seq, _ = timestep.shape\n    rows = int(batch * seq)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/diffusion/modulate/ltx2_ada_values_triton.py#L131-L167","documentation":"ltx2_ada_values9 expects scale_shift_table with shape [9, D] — nine rows (one per modulation parameter) and hidden dim D. A tensor with a different rank or a first dimension != 9 fails this check.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nvals = ltx2_ada_values9(table_6row, t)\n# after\nassert table.shape[0] == 9\nvals = ltx2_ada_values9(table, t)","handlingStrategy":"validation","validationCode":"assert scale_shift_table.ndim == 2 and scale_shift_table.shape[0] == 9","typeGuard":"def table_ok(t: torch.Tensor) -> bool:\n    return t.dim() == 2 and t.shape[0] == 9","tryCatchPattern":null,"preventionTips":["Validate checkpoint params against expected [9, D] at load time","Don't reuse non-LTX2 AdaLN tables"],"tags":["shape","ltx2","checkpoint","adaln"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}