This commit is contained in:
Disty0
2026-07-15 22:29:28 +03:00
parent 5409df20a8
commit 00231ab035
2 changed files with 6 additions and 2 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ from ...kernel_wrappers import use_contiguous_int8_mm, use_contiguous_fp16_mm, u
def check_mats(input: torch.Tensor, weight: torch.Tensor, matmul_dtype: str = "int8") -> tuple[torch.Tensor, torch.Tensor]:
input = input.contiguous()
if input is not None:
input = input.contiguous()
if (
(use_contiguous_int8_mm and matmul_dtype in {"int8", "uint8"})
or (use_contiguous_fp16_mm and matmul_dtype in {"fp16", "float16"})
+4 -1
View File
@@ -3,7 +3,7 @@
import torch
from modules import devices
from .common import dtype_dict, conv_types, conv_transpose_types
from .common import dtype_dict, compile_func, conv_types, conv_transpose_types
from .kernel_wrappers import use_contiguous_int8_mm, use_contiguous_fp16_mm, use_contiguous_fp8_mm
from .utils import is_pow2, is_pow4, next_power_of_2
@@ -229,3 +229,6 @@ def quantize_fp_mm(weight: torch.FloatTensor, dim: int = -1, hadamard: torch.Flo
weight = weight.add_(torch.randint_like(weight, low=0, high=mantissa_difference, dtype=torch.int32)).bitwise_and_(-mantissa_difference).view(dtype=torch.float32)
weight = torch.div(weight, scale).nan_to_num_().clamp_(dtype_dict[matmul_dtype]["min"], dtype_dict[matmul_dtype]["max"]).to(dtype=dtype_dict[matmul_dtype]["torch_dtype"])
return weight, scale
rotate_hadamard_compiled = compile_func(rotate_hadamard)