Skip to content

Commit

Permalink
dtype asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Panferov committed Feb 7, 2024
1 parent f019b4e commit d90c43b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions inference_lib/src/aqlm/inference_kernels/kernel_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ def forward_pass_quantized_linear(
case (True, 1, 65536, 1, 8):
from .cuda_kernel import CUDA_KERNEL

assert (
input.dtype == torch.float16
), f"please load the model with `torch_dtype=torch.float16`, as {input.dtype} is not supported on GPU yet"
return CUDA_KERNEL.code1x16_matmat(input, codes, codebooks, scales) + (bias if bias is not None else 0)
case (True, 2, 256, 1, 8):
from .cuda_kernel import CUDA_KERNEL

assert (
input.dtype == torch.float16
), f"please load the model with `torch_dtype=torch.float16`, as {input.dtype} is not supported on GPU yet"
return CUDA_KERNEL.code2x8_matmat(input, codes, codebooks, scales) + (bias if bias is not None else 0)
case (True, _, _, _, _):
from .triton_kernel import triton_matmul
Expand Down
2 changes: 1 addition & 1 deletion inference_lib/src/aqlm/inference_kernels/numba_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def numba_gemm_lut(
assert in_features % in_group_size == 0
assert codebook_size == 2**8
assert codes.dtype == torch.int8
assert input.dtype == torch.float32 and codebooks.dtype == torch.float32
assert input.dtype == torch.float32 and codebooks.dtype == torch.float32, f"please load the model with `torch_dtype=torch.float32`, as {input.dtype} is not supported for CPU"

kernel_key = (in_group_size, out_features, in_features, num_codebooks)
if kernel_key not in COMPILED_KERNELS:
Expand Down

0 comments on commit d90c43b

Please sign in to comment.