File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 7
7
import torch
8
8
import torch .nn .functional as F
9
9
10
- from torchao .quantization .GPTQ .GPTQ import _check_linear_int4_k
11
10
from torchao .quantization .unified import Quantizer
12
11
from torchao .quantization .utils import groupwise_affine_quantize_tensor
13
12
14
13
14
+ # TODO: import from from torchao.quantization.GPTQ.GPTQ import _check_linear_int4_k
15
+ # Once diff train catches up
16
+ def _check_linear_int4_k (k , group_size = 1 , inner_k_tiles = None ):
17
+ """
18
+ Check if the dimensions are compatible with int4 quantization.
19
+
20
+ Args:
21
+ k: The dimension size to check
22
+ group_size: The group size for quantization
23
+ inner_k_tiles: The inner k tiles size
24
+
25
+ Returns:
26
+ bool: Whether the dimensions are compatible
27
+ """
28
+ k_divisible_by_group_size = k % group_size == 0
29
+ if inner_k_tiles is not None :
30
+ k_divisible_by_16_times_inner_k_tiles = k % (inner_k_tiles * 16 ) == 0
31
+ return k_divisible_by_group_size and k_divisible_by_16_times_inner_k_tiles
32
+ return k_divisible_by_group_size
33
+
34
+
15
35
# This module is copied from torchao.quantization.GPTQ.WeightOnlyInt4Linear with
16
36
# changes at the annotated lines.
17
37
class VkWeightOnlyInt4Linear (torch .nn .Module ):
You can’t perform that action at this time.
0 commit comments