{"record":{"id":"013865a3822cabe2","repo":"huggingface/transformers","slug":"failed-to-load-kernels-community-deep-gemm-che","errorCode":null,"errorMessage":"Failed to load `kernels-community/deep-gemm` — check that a build matches the current torch/CUDA.","messagePattern":"Failed to load `kernels-community/deep-gemm` — check that a build matches the current torch/CUDA\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/deepgemm.py","lineNumber":250,"sourceCode":"def _load_deepgemm_kernel() -> None:\n    \"\"\"Load DeepGEMM once into the `_DEEPGEMM` module global, raising `ImportError` if the env or any\n    required symbol is missing. Under NO circumstances may this function return a value: it rides\n    through `@allow_in_graph` as an opaque fx node, whose return must be proxyable — returning the\n    bundle (e.g. from the warm-cache short-circuit) breaks torch.compile with\n    `Unsupported: torch.* op returned non-Tensor`. Callers read `_DEEPGEMM` back from the global.\n\n    `@allow_in_graph` makes `torch.compile` treat the untraceable cold path (hub download + dynamic\n    import via `lazy_load_kernel`) as a single opaque node instead of tracing into it; it returns `None`\n    (proxyable) and populates the global, which `load_deepgemm_kernel` then returns.\n    \"\"\"\n    global _DEEPGEMM\n    if _DEEPGEMM is not None:\n        return\n\n    is_deepgemm_loadable(raise_error=True)\n    kernel = lazy_load_kernel(\"deep-gemm\")\n    if kernel is None:\n        raise ImportError(\n            \"Failed to load `kernels-community/deep-gemm` — check that a build matches the current torch/CUDA.\"\n        )\n\n    fp8_fp4_matmul = getattr(kernel, \"fp8_fp4_gemm_nt\", None)\n    grouped_fp8_fp4_matmul_nt = getattr(kernel, \"m_grouped_fp8_fp4_gemm_nt_contiguous\", None)\n    grouped_fp8_fp4_matmul_nn = getattr(kernel, \"m_grouped_fp8_fp4_gemm_nn_contiguous\", None)\n    grouped_bf16_matmul_nt = getattr(kernel, \"m_grouped_bf16_gemm_nt_contiguous\", None)\n    grouped_bf16_matmul_nn = getattr(kernel, \"m_grouped_bf16_gemm_nn_contiguous\", None)\n    per_token_cast_to_fp8 = resolve_internal_import(kernel, chained_path=\"utils.per_token_cast_to_fp8\")\n    transform_sf_into_required_layout = getattr(kernel, \"transform_sf_into_required_layout\", None)\n    transform_weights_for_mega_moe = getattr(kernel, \"transform_weights_for_mega_moe\", None)\n    get_symm_buffer_for_mega_moe = getattr(kernel, \"get_symm_buffer_for_mega_moe\", None)\n    get_mk_alignment = getattr(kernel, \"get_mk_alignment_for_contiguous_layout\", None)\n    fp8_fp4_mega_moe = getattr(kernel, \"fp8_fp4_mega_moe\", None)\n\n    missing = [\n        name\n        for name, attr in [","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/deepgemm.py#L232-L268","documentation":"Error \"Failed to load `kernels-community/deep-gemm` — check that a build matches the current torch/CUDA.\" thrown in huggingface/transformers.","triggerScenarios":"Raised when loading the kernels-community/deep-gemm kernel fails due to a torch/CUDA build mismatch.","commonSituations":"Using DeepGEMM FP8 quantization on a torch/CUDA combination with no prebuilt deep-gemm kernel.","solutions":["Install/update the kernels package so `kernels-community/deep-gemm` has a build matching your torch/CUDA: `pip install -U kernels`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}