{"record":{"id":"f830f0c5f9eb515f","repo":"huggingface/transformers","slug":"deepgemm-linear-does-not-support-static-activation","errorCode":null,"errorMessage":"DeepGEMM linear does not support static activation quantization.","messagePattern":"DeepGEMM linear does not support static activation quantization\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/deepgemm.py","lineNumber":593,"sourceCode":"\n\n@deprecate_kwarg(\"output_dtype\", version=\"v5.16\")\ndef deepgemm_fp8_fp4_linear(\n    input: torch.Tensor,\n    weight: torch.Tensor,\n    weight_scale_inv: torch.Tensor,\n    bias: torch.Tensor | None = None,\n    block_size: tuple[int, int] | None = None,\n    output_dtype: torch.dtype | None = None,\n    activation_scale: torch.Tensor | None = None,\n) -> torch.Tensor:\n    \"\"\"End-to-end DeepGEMM linear: per-token activation quant + FP8/FP4 matmul.\n\n    Static (per-tensor) activation quantization is rejected — DeepGEMM needs\n    per-row SFs. Callers should route static activations through the Triton fallback.\n    \"\"\"\n    if activation_scale is not None:\n        raise NotImplementedError(\"DeepGEMM linear does not support static activation quantization.\")\n    if input.dtype not in (torch.bfloat16, torch.float16):\n        raise ValueError(f\"DeepGEMM linear requires FP16 or BF16 activations, got {input.dtype}\")\n\n    # Fail before the (hub-download + JIT) load if this device can't serve these dtypes.\n    _assert_sm100_requirements(weight, weight_scale_inv)\n\n    deepgemm = load_deepgemm_kernel()\n    cast_kwargs = _select_fp8_cast_kwargs(weight, weight_scale_inv, block_size, is_sm100())\n\n    input_2d = input.view(-1, input.shape[-1])\n    qinput_2d, scale_2d = deepgemm.per_token_cast_to_fp8(input_2d, **cast_kwargs)\n    output = torch.empty(qinput_2d.shape[0], weight.shape[0], device=input.device, dtype=input.dtype)\n\n    # Pass `(1, 1, gran_k)` for int-SF paths so the kernel uses the right K granularity\n    # (the default `(1, 1, 128)` mismatches FP4's gran_k=32). Float-SF leaves it None.\n    sf_recipe = (1, 1, cast_kwargs[\"gran_k\"]) if cast_kwargs.get(\"use_packed_ue8m0\") else None\n    deepgemm.fp8_fp4_matmul(\n        (qinput_2d, _coerce_sf_for_kernel(scale_2d, is_sm100(), expected_mn=qinput_2d.size(0))),","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/deepgemm.py#L575-L611","documentation":"Error \"DeepGEMM linear does not support static activation quantization.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in DeepGEMM linear forward when activation_scheme is 'static' quantization.","commonSituations":"Static-quantized activations passed to DeepGEMM linear layers, which only support dynamic activation quantization.","solutions":["Use dynamic activation quantization instead of static for DeepGEMM linear.","Switch to an implementation supporting static activation quantization."],"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"}