{"record":{"id":"1b6c468c3f230896","repo":"sgl-project/sglang","slug":"unsupported-input-for-causal-conv3d-cat-pad-cuda","errorCode":null,"errorMessage":"unsupported input for causal Conv3D cat/pad CUDA","messagePattern":"unsupported input for causal Conv3D cat/pad CUDA","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/diffusion/layout/causal_conv3d_cat_pad_jit.py","lineNumber":115,"sourceCode":"\ndef fused_causal_conv3d_cat_pad_cuda(\n    x: torch.Tensor,\n    cache_x: torch.Tensor,\n    padding: list[int] | tuple[int, ...],\n) -> torch.Tensor:\n    if x.dtype not in _SUPPORTED_DTYPES:\n        raise RuntimeError(f\"unsupported dtype for causal Conv3D cat/pad: {x.dtype}\")\n    if not torch.compiler.is_compiling():\n        if (\n            not x.is_cuda\n            or not cache_x.is_cuda\n            or x.dim() != 5\n            or cache_x.dim() != 5\n            or not x.is_contiguous()\n            or not cache_x.is_contiguous()\n            or not can_use_fused_causal_conv3d_cat_pad_cuda(x, cache_x, padding)\n        ):\n            raise RuntimeError(\"unsupported input for causal Conv3D cat/pad CUDA\")\n    return _causal_conv3d_cat_pad_custom_op(x, cache_x, *padding)\n\n\ndef can_use_fused_causal_conv3d_cat_pad_cuda(\n    x: torch.Tensor,\n    cache_x: torch.Tensor,\n    padding: list[int] | tuple[int, ...],\n) -> bool:\n    if x.dtype not in _SUPPORTED_DTYPES:\n        return False\n    pad_w_left, pad_w_right, pad_h_top, pad_h_bottom, pad_d_left, pad_d_right = padding\n    cache_t = cache_x.shape[2]\n    depth_left = pad_d_left - cache_t\n    if depth_left < 0 or pad_d_right != 0:\n        return False\n    out_numel = (\n        x.shape[0]\n        * x.shape[1]","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/diffusion/layout/causal_conv3d_cat_pad_jit.py#L97-L133","documentation":"The CUDA fused path for causal Conv3D cat/pad only runs on 5D, contiguous CUDA tensors whose padding configuration is accepted by can_use_fused_causal_conv3d_cat_pad_cuda. Any deviation (CPU tensor, wrong rank, non-contiguous memory, or an unsupported padding layout) triggers this guard.","triggerScenarios":"Calling fused_causal_conv3d_cat_pad_cuda with non-CUDA tensors, tensors whose dim() != 5, non-contiguous x or cache_x (e.g. sliced/permuted views), or padding values the fused kernel cannot handle (checked by can_use_fused_causal_conv3d_cat_pad_cuda).","commonSituations":"Passing a permuted/sliced activation from a prior layer without calling .contiguous(); running the diffusion pipeline with padding configs only the Triton/eager fallback supports; accidental CPU tensors in tests.","solutions":["Call .contiguous() on x and cache_x before invoking","Verify x.dim() == 5 and both tensors are on CUDA","Pre-check with can_use_fused_causal_conv3d_cat_pad_cuda(x, cache_x, padding) and use the fused_causal_conv3d_cat_pad dispatcher or eager fallback otherwise","Adjust padding to a supported configuration"],"exampleFix":"# before\ny = fused_causal_conv3d_cat_pad_cuda(x[::1], cache, padding)\n# after\nx = x.contiguous(); cache = cache.contiguous()\ny = fused_causal_conv3d_cat_pad_cuda(x, cache, padding) if can_use_fused_causal_conv3d_cat_pad_cuda(x, cache, padding) else eager_path(x, cache, padding)","handlingStrategy":"validation","validationCode":"from sglang.kernels.ops.diffusion.layout.causal_conv3d_cat_pad_jit import can_use_fused_causal_conv3d_cat_pad_cuda\nx = x.contiguous(); cache_x = cache_x.contiguous()\nassert x.is_cuda and x.dim() == 5\nuse_fused = can_use_fused_causal_conv3d_cat_pad_cuda(x, cache_x, padding)","typeGuard":"def usable(x, c, p) -> bool:\n    return x.is_cuda and c.is_cuda and x.dim() == 5 and c.dim() == 5 and x.is_contiguous() and c.is_contiguous() and can_use_fused_causal_conv3d_cat_pad_cuda(x, c, p)","tryCatchPattern":null,"preventionTips":["Always .contiguous() after slicing/permute","Use the dispatcher fused_causal_conv3d_cat_pad which picks a working path"],"tags":["cuda","contiguity","conv3d","input-validation"],"backgroundTag":"tensor-input-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}