[CPU] Add FP8 W8A16 linear support (#41186)

Signed-off-by: yuwenzho <yuwen.zhou@intel.com>
This commit is contained in:
Yuwen Zhou
2026-05-06 07:05:27 +00:00
committed by GitHub
parent b53c507bc9
commit 809b98e5b7
9 changed files with 331 additions and 3 deletions
+33
View File
@@ -3219,6 +3219,39 @@ if hasattr(torch.ops._C, "int4_scaled_mm_cpu"):
_supports_cpu_w4a8_int8 = bool(hasattr(torch.ops._C, "convert_weight_packed_scale_zp"))
if hasattr(torch.ops._C, "fp8_scaled_mm_cpu"):
@register_fake("_C::fp8_scaled_mm_cpu")
def fp8_scaled_mm_cpu_fake(
mat1: torch.Tensor,
mat2: torch.Tensor,
scales2: torch.Tensor,
block_size: list[int],
bias: torch.Tensor | None,
out_dtype: torch.dtype,
is_vnni: bool,
) -> torch.Tensor:
M = mat1.size(0)
N = mat2.size(0)
return torch.empty((M, N), dtype=out_dtype, device=mat1.device)
_supports_cpu_fp8_w8a16 = bool(hasattr(torch.ops._C, "fp8_scaled_mm_cpu"))
def fp8_scaled_mm_cpu(
mat1: torch.Tensor,
mat2: torch.Tensor,
scales2: torch.Tensor,
block_size: list[int],
bias: torch.Tensor | None,
out_dtype: torch.dtype,
is_vnni: bool,
) -> torch.Tensor:
return torch.ops._C.fp8_scaled_mm_cpu(
mat1, mat2, scales2, block_size, bias, out_dtype, is_vnni
)
class CPUDNNLGEMMHandler:
def __init__(self) -> None: