{"record":{"id":"8062d21e455190d8","repo":"sgl-project/sglang","slug":"tgv-cute-ext-output-supports-list-torch-to-cutla","errorCode":null,"errorMessage":"TGV cute_ext output supports {list(_TORCH_TO_CUTLASS_OUT_DTYPE)}; got {c_dtype}.","messagePattern":"TGV cute_ext output supports (.+?); got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/gemm/cutedsl_bf16_gemm.py","lineNumber":1144,"sourceCode":"        cta_k,\n        num_ab_stage,\n        bool(use_2cta),\n        bool(use_pdl),\n        bool(has_bias),\n        a_leading,\n        b_leading,\n        c_leading,\n    )\n    cached = _TGV_CUTE_EXT_COMPILE_CACHE.get(key)\n    if cached is not None:\n        return cached\n\n    if dtype not in _TORCH_TO_CUTLASS_DTYPE:\n        raise ValueError(\n            f\"TGV cute_ext backend supports {list(_TORCH_TO_CUTLASS_DTYPE)}; got {dtype}.\"\n        )\n    if c_dtype not in _TORCH_TO_CUTLASS_OUT_DTYPE:\n        raise ValueError(\n            f\"TGV cute_ext output supports {list(_TORCH_TO_CUTLASS_OUT_DTYPE)}; \"\n            f\"got {c_dtype}.\"\n        )\n\n    gemm = TgvGemmCuteExtKernel(\n        acc_dtype=cutlass.Float32,\n        cta_m=cta_m,\n        cta_n=cta_n,\n        cta_k=cta_k,\n        num_ab_stage=num_ab_stage,\n        use_2cta=use_2cta,\n        use_pdl=use_pdl,\n        has_bias=has_bias,\n        out_dtype=_TORCH_TO_CUTLASS_OUT_DTYPE[c_dtype],\n    )\n\n    a_, b_, c_, bias_ = _make_compile_repr_tensors(\n        dtype,","sourceCodeStart":1126,"sourceCodeEnd":1162,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/gemm/cutedsl_bf16_gemm.py#L1126-L1162","documentation":"The TGV cute_ext backend constrains the output/accumulate dtype to _TORCH_TO_CUTLASS_OUT_DTYPE (bf16/fp32). Requesting e.g. fp16 or fp8 output raises before compilation.","triggerScenarios":"Calling _run_tgv with an out tensor or c_dtype of torch.float16, torch.float8, or int types.","commonSituations":"Configs tuned for other backends where fp16 output is allowed, then reused with the TGV path.","solutions":["Use bfloat16 or float32 output.","Add an explicit cast of the result after the GEMM if fp16 is needed downstream.","Check _TORCH_TO_CUTLASS_OUT_DTYPE keys before configuring."],"exampleFix":"// before\nout = torch.empty(M, N, dtype=torch.float16, device='cuda')\n// after\nout = torch.empty(M, N, dtype=torch.bfloat16, device='cuda')\n# cast later if needed: out.half()","handlingStrategy":"type-guard","validationCode":"assert out.dtype in _TORCH_TO_CUTLASS_OUT_DTYPE","typeGuard":"def tgv_output_ok(t: torch.Tensor) -> bool:\n    return t.dtype in _TORCH_TO_CUTLASS_OUT_DTYPE","tryCatchPattern":null,"preventionTips":["Allocate out as bf16 or fp32.","Cast downstream if another precision is needed."],"tags":["gemm","tgv","output-dtype","cutlass"],"backgroundTag":"unsupported-dtype-for-kernel","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}