[CompressedTensors] FP4 Qutlass Integration (#43229)

Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <brian-dellabetta@users.noreply.github.com>
Co-authored-by: Brian Dellabetta <bdellabe@redhat.com>
Co-authored-by: Brian Dellabetta <brian-dellabetta@users.noreply.github.com>
Co-authored-by: Dipika Sikka <dipikasikka1@gmail.com>
This commit is contained in:
Kyle Sayers
2026-07-28 20:34:20 -06:00
committed by GitHub
co-authored by Brian Dellabetta Brian Dellabetta Dipika Sikka
parent 7398a30d79
commit 30c2718eaa
7 changed files with 169 additions and 34 deletions
+34 -3
View File
@@ -3994,9 +3994,40 @@ def fusedQuantizeNv(
padded_rows, padded_cols, dtype=torch.float8_e4m3fn, device=a.device
)
return torch.ops._qutlass_C.fusedQuantizeNvAbsMax(
a, b, xh_e2m1, xh_e4m3, global_scale
)
safeFusedQuantizeNv(a, b, xh_e2m1, xh_e4m3, global_scale)
return xh_e2m1, xh_e4m3
@torch.library.custom_op(
"vllm::safeFusedQuantizeNv", mutates_args=("xh_e2m1", "xh_e4m3")
)
def safeFusedQuantizeNv(
a: torch.Tensor,
b: torch.Tensor,
xh_e2m1: torch.Tensor,
xh_e4m3: torch.Tensor,
global_scale: torch.Tensor,
) -> None:
"""
Wrapper for QUTLASS fusedQuantizeNv method that operates on tensors in-place
rather than returning them, to prevent torch 2.12+ errors that outputs of custom
operators may not alias any inputs to the custom operator.
"""
torch.ops._qutlass_C.fusedQuantizeNvAbsMax(a, b, xh_e2m1, xh_e4m3, global_scale)
return
if hasattr(torch.ops._qutlass_C, "fusedQuantizeNv"):
@register_fake("vllm::safeFusedQuantizeNv")
def _fake_fused_quantize_nv(
a: torch.Tensor,
b: torch.Tensor,
xh_e2m1: torch.Tensor,
xh_e4m3: torch.Tensor,
global_scale: torch.Tensor,
) -> None:
return
def hadacore_transform(x: torch.Tensor, inplace: bool = True) -> torch.Tensor: