{"record":{"id":"a965e0c0cfdc473a","repo":"sgl-project/sglang","slug":"unsupported-dtype-for-causal-conv3d-cat-pad-x-dt","errorCode":null,"errorMessage":"unsupported dtype for causal Conv3D cat/pad: {x.dtype}","messagePattern":"unsupported dtype for causal Conv3D cat/pad: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/diffusion/layout/causal_conv3d_cat_pad_jit.py","lineNumber":104,"sourceCode":"        x,\n        cache_x,\n        pad_w_left,\n        pad_w_right,\n        pad_h_top,\n        pad_h_bottom,\n        pad_d_left,\n        pad_d_right,\n    )\n    return out\n\n\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, ...],","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/diffusion/layout/causal_conv3d_cat_pad_jit.py#L86-L122","documentation":"The fused causal Conv3D cat/pad CUDA kernel only supports a fixed set of dtypes (defined in _SUPPORTED_DTYPES in causal_conv3d_cat_pad_jit.py). When the input tensor x has a dtype outside that set, the wrapper raises immediately rather than compiling a kernel variant for it.","triggerScenarios":"Calling fused_causal_conv3d_cat_pad_cuda (directly or via fused_causal_conv3d_cat_pad) with x in an unsupported dtype such as float64 or an integer/bool dtype, while cache_x is concatenated onto x for a causal Conv3D layer.","commonSituations":"Running a diffusion model (e.g. LTX2-style video models) whose activations were cast to fp64 for debugging, or feeding fp8/int activations; mixing new dtypes not yet added to the JIT kernel's supported list.","solutions":["Check x.dtype against _SUPPORTED_DTYPES (fp16/bf16/fp32) before calling","Cast the input: x = x.to(torch.bfloat16) (and cache_x likewise)","Fall back to the eager PyTorch path (torch.cat + F.pad) for unsupported dtypes","Extend _SUPPORTED_DTYPES and regenerate the JIT kernel if you truly need a new dtype"],"exampleFix":"# before\nout = fused_causal_conv3d_cat_pad_cuda(x_fp64, cache, padding)\n# after\nx = x.to(torch.bfloat16); cache = cache.to(torch.bfloat16)\nout = fused_causal_conv3d_cat_pad_cuda(x, cache, padding)","handlingStrategy":"type-guard","validationCode":"from sglang.kernels.ops.diffusion.layout.causal_conv3d_cat_pad_jit import _SUPPORTED_DTYPES\nif x.dtype not in _SUPPORTED_DTYPES:\n    x = x.to(torch.bfloat16); cache_x = cache_x.to(torch.bfloat16)","typeGuard":"def conv3d_dtype_ok(x: torch.Tensor) -> bool:\n    return x.dtype in (torch.float16, torch.bfloat16, torch.float32)","tryCatchPattern":null,"preventionTips":["Standardize diffusion activations on bf16/fp16 pipeline-wide","Assert dtype at pipeline entry"],"tags":["cuda","dtype","conv3d","diffusion"],"backgroundTag":"unsupported-dtype","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}