{"record":{"id":"c5413f5468cf83ea","repo":"sgl-project/sglang","slug":"unsupported-interleaved-rope-fp64-dtype-dtype","errorCode":null,"errorMessage":"Unsupported interleaved_rope_fp64 dtype: {dtype}","messagePattern":"Unsupported interleaved_rope_fp64 dtype: (.+?)","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/diffusion/rope/interleaved_rope_fp64_jit.py","lineNumber":17,"sourceCode":"from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport torch\n\nfrom sglang.kernels.jit.utils import cache_once, load_jit, make_cpp_args\nfrom sglang.srt.utils.custom_op import register_custom_op\n\nif TYPE_CHECKING:\n    from tvm_ffi.module import Module\n\n\n@cache_once\ndef _jit_interleaved_rope_fp64_module(dtype: torch.dtype) -> Module:\n    if dtype is not torch.bfloat16:\n        raise RuntimeError(f\"Unsupported interleaved_rope_fp64 dtype: {dtype}\")\n    args = make_cpp_args(dtype)\n    return load_jit(\n        \"diffusion_interleaved_rope_fp64\",\n        *args,\n        cuda_files=[\"diffusion/interleaved_rope_fp64.cuh\"],\n        cuda_wrappers=[\n            (\n                \"interleaved_rope_fp64\",\n                f\"interleaved_rope_fp64::InterleavedRopeFP64Kernel<{args}>::run\",\n            ),\n        ],\n    )\n\n\ndef _fake_impl(\n    q: torch.Tensor,\n    k: torch.Tensor,\n    cos: torch.Tensor,","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/diffusion/rope/interleaved_rope_fp64_jit.py#L1-L35","documentation":"The JIT-compiled interleaved RoPE fp64 kernel is specialized for bfloat16 only; the template instantiation for other dtypes is not built. Passing float16 or float32 triggers this RuntimeError at module compile time.","triggerScenarios":"Calling fused_interleaved_rope_fp64 with a fp16/fp32 Q or K tensor; the dtype check happens before load_jit.","commonSituations":"Running a diffusion model variant configured for fp16 instead of bf16, or casting inputs to fp32 for debugging.","solutions":["Cast Q/K to torch.bfloat16 before calling fused_interleaved_rope_fp64.","Change the model's dtype config to bfloat16.","Use a fallback RoPE implementation if another dtype is required."],"exampleFix":"// before\nq = q.to(torch.float16)\nout = fused_interleaved_rope_fp64(q, k, cos, sin)\n// after\nq = q.to(torch.bfloat16)\nk = k.to(torch.bfloat16)\nout = fused_interleaved_rope_fp64(q, k, cos, sin)","handlingStrategy":"validation","validationCode":"if q.dtype is not torch.bfloat16:\n    q, k = q.bfloat16(), k.bfloat16()","typeGuard":"def is_bf16(t: torch.Tensor) -> bool:\n    return t.dtype is torch.bfloat16","tryCatchPattern":null,"preventionTips":["Load diffusion models in bfloat16.","Centralize dtype policy at model init."],"tags":["jit","dtype","bfloat16","rope"],"backgroundTag":"unsupported-dtype-for-kernel","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}