{"record":{"id":"76fc8719ee2c669a","repo":"sgl-project/sglang","slug":"d-d-not-supported-must-be-multiple-of-256-and","errorCode":null,"errorMessage":"D={D} not supported, must be multiple of 256 and <= 8192","messagePattern":"D=(.+?) not supported, must be multiple of 256 and <= 8192","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/diffusion/norm/scale_residual_norm_cutedsl.py","lineNumber":287,"sourceCode":"\n    native_y = _try_qwen_native_norm_scale_shift(\n        x, weight, bias, scale, shift, norm_type, eps\n    )\n    if native_y is not None:\n        return native_y\n    stream = cuda.CUstream(torch.cuda.current_stream().cuda_stream)\n    # Tensor Validation\n    BSD = x.shape\n    validate_x(x, *BSD)\n    validate_weight_bias(weight, BSD[-1])\n    validate_weight_bias(bias, BSD[-1])\n    validate_scale_shift(scale, *BSD)\n    validate_scale_shift(shift, *BSD)\n\n    if norm_type == \"layer\" or norm_type == \"rms\":\n        D = x.shape[-1]\n        if D % 256 != 0 or D > 8192:\n            raise ValueError(\n                f\"D={D} not supported, must be multiple of 256 and <= 8192\"\n            )\n        y = torch.empty_like(x)  # create output tensor\n        scale = broadcast_tensor_for_bsfd(scale, *x.shape)  # handle various shapes\n        shift = broadcast_tensor_for_bsfd(shift, *x.shape)  # handle various shapes\n        # Use scalar placeholders for None tensors as a workaround, since the CuTe DSL\n        # TVM-FFI backend does not support None parameters. scalar values do not result\n        # in code generation and have no impact on runtime performance.\n        weight = 1 if weight is None else weight\n        bias = 0 if bias is None else bias\n        ResOut, Residual, Gate = 0, 0, 1\n        torch_tensors = [y, ResOut, Residual, x, Gate, weight, bias, scale, shift]\n        # Compile cache\n        hash_key = ScaleResidualNormScaleShift.make_hash_key(norm_type, *torch_tensors)\n        compiled_fn = _COMPILE_CACHE.get(hash_key)\n        if compiled_fn is None:\n            kernel = ScaleResidualNormScaleShift(D, norm_type)\n            fake_sig_args = [to_fake_cute_args(t) for t in torch_tensors]","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/diffusion/norm/scale_residual_norm_cutedsl.py#L269-L305","documentation":"The CuTe DSL kernel tiles the hidden dimension in 256-wide blocks and is only compiled for D up to 8192. fused_norm_scale_shift rejects hidden sizes that are not a multiple of 256 or exceed 8192.","triggerScenarios":"Calling fused_norm_scale_shift with norm_type 'layer' or 'rms' when x.shape[-1] (D) is not divisible by 256 or is > 8192 (e.g. D=1000, D=6144, or D=16384).","commonSituations":"Small test models with odd hidden sizes, or very wide MLP hidden dims routed through this fused path by mistake.","solutions":["Route such shapes to the eager torch.nn.functional.layer_norm / RMSNorm fallback","Pad D to the next multiple of 256 if padding is semantically acceptable","Reconfigure the model's hidden size to a multiple of 256 (design-time fix)"],"exampleFix":"# before\ny = fused_norm_scale_shift(x, w, b, scale, shift, \"rms\")  # D=1000\n# after\nif D % 256 == 0 and D <= 8192:\n    y = fused_norm_scale_shift(x, w, b, scale, shift, \"rms\")\nelse:\n    y = torch.nn.functional.rms_norm(x, (D,), w, eps)  # fallback","handlingStrategy":"fallback","validationCode":"D = x.shape[-1]\nuse_fused = (D % 256 == 0 and D <= 8192)","typeGuard":"def d_supported(D: int) -> bool:\n    return D % 256 == 0 and D <= 8192","tryCatchPattern":"try:\n    y = fused_norm_scale_shift(...)\nexcept ValueError:\n    y = torch.nn.functional.layer_norm(x * scale + shift if False else x, (D,), weight, bias, eps)  # eager fallback","preventionTips":["Gate fused path on D % 256 == 0 and D <= 8192","Keep an eager norm fallback wired in for odd widths"],"tags":["shape-constraint","cuda-kernel","diffusion","norm"],"backgroundTag":"unsupported-hidden-dimension","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}