tico 0.1.0.dev251102__py3-none-any.whl → 0.1.0.dev251106__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tico/__init__.py +1 -1
- tico/quantization/algorithm/gptq/gptq.py +23 -2
- tico/quantization/wrapq/wrappers/nn/quant_silu.py +5 -4
- tico/quantization/wrapq/wrappers/registry.py +5 -2
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/METADATA +1 -1
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/RECORD +10 -10
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/LICENSE +0 -0
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/WHEEL +0 -0
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/entry_points.txt +0 -0
- {tico-0.1.0.dev251102.dist-info → tico-0.1.0.dev251106.dist-info}/top_level.txt +0 -0
tico/__init__.py
CHANGED
|
@@ -36,6 +36,11 @@ class GPTQ:
|
|
|
36
36
|
self.layer = layer
|
|
37
37
|
self.dev = self.layer.weight.device
|
|
38
38
|
W = layer.weight.data.clone()
|
|
39
|
+
if isinstance(self.layer, nn.Conv2d):
|
|
40
|
+
W = W.flatten(1)
|
|
41
|
+
|
|
42
|
+
if isinstance(self.layer, nn.Conv1d):
|
|
43
|
+
W = W.t()
|
|
39
44
|
self.rows = W.shape[0]
|
|
40
45
|
self.columns = W.shape[1]
|
|
41
46
|
self.H: Optional[torch.Tensor] = torch.zeros(
|
|
@@ -48,10 +53,22 @@ class GPTQ:
|
|
|
48
53
|
if len(inp.shape) == 2:
|
|
49
54
|
inp = inp.unsqueeze(0)
|
|
50
55
|
tmp = inp.shape[0]
|
|
51
|
-
if isinstance(self.layer, nn.Linear):
|
|
52
|
-
if len(inp.shape)
|
|
56
|
+
if isinstance(self.layer, nn.Linear) or isinstance(self.layer, nn.Conv1d):
|
|
57
|
+
if len(inp.shape) > 2:
|
|
53
58
|
inp = inp.reshape((-1, inp.shape[-1]))
|
|
54
59
|
inp = inp.t()
|
|
60
|
+
if isinstance(self.layer, nn.Conv2d):
|
|
61
|
+
unfold = nn.Unfold(
|
|
62
|
+
self.layer.kernel_size,
|
|
63
|
+
dilation=self.layer.dilation,
|
|
64
|
+
padding=self.layer.padding,
|
|
65
|
+
stride=self.layer.stride,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
inp = unfold(inp)
|
|
69
|
+
inp = inp.permute([1, 0, 2])
|
|
70
|
+
inp = inp.flatten(1)
|
|
71
|
+
|
|
55
72
|
self.H *= self.nsamples / (self.nsamples + tmp)
|
|
56
73
|
self.nsamples += tmp
|
|
57
74
|
inp = math.sqrt(2 / self.nsamples) * inp.float()
|
|
@@ -67,6 +84,10 @@ class GPTQ:
|
|
|
67
84
|
verbose=False,
|
|
68
85
|
):
|
|
69
86
|
W = self.layer.weight.data.clone()
|
|
87
|
+
if isinstance(self.layer, nn.Conv2d):
|
|
88
|
+
W = W.flatten(1)
|
|
89
|
+
if isinstance(self.layer, nn.Conv1d):
|
|
90
|
+
W = W.t()
|
|
70
91
|
W = W.float()
|
|
71
92
|
tick = time.time()
|
|
72
93
|
if not self.quantizer.ready():
|
|
@@ -19,14 +19,15 @@ import torch.nn as nn
|
|
|
19
19
|
|
|
20
20
|
from tico.quantization.config.ptq import PTQConfig
|
|
21
21
|
from tico.quantization.wrapq.wrappers.quant_module_base import QuantModuleBase
|
|
22
|
-
from tico.quantization.wrapq.wrappers.registry import
|
|
22
|
+
from tico.quantization.wrapq.wrappers.registry import try_register
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
@
|
|
25
|
+
@try_register("torch.nn.SiLU", "transformers.activations.SiLUActivation")
|
|
26
26
|
class QuantSiLU(QuantModuleBase):
|
|
27
27
|
"""
|
|
28
|
-
QuantSiLU — drop-in
|
|
29
|
-
|
|
28
|
+
QuantSiLU — drop-in quantized implementation of the SiLU operation.
|
|
29
|
+
|
|
30
|
+
This module quantizes both intermediate tensors:
|
|
30
31
|
• s = sigmoid(x) (logistic)
|
|
31
32
|
• y = x * s (mul)
|
|
32
33
|
"""
|
|
@@ -23,14 +23,17 @@ _WRAPPERS: Dict[Type[nn.Module], Type[QuantModuleBase]] = {}
|
|
|
23
23
|
_IMPORT_ONCE = False
|
|
24
24
|
_CORE_MODULES = (
|
|
25
25
|
"tico.quantization.wrapq.wrappers.quant_elementwise",
|
|
26
|
+
## nn ##
|
|
26
27
|
"tico.quantization.wrapq.wrappers.nn.quant_layernorm",
|
|
27
28
|
"tico.quantization.wrapq.wrappers.nn.quant_linear",
|
|
29
|
+
# This includes not only `nn.SiLU` but also `SiLUActivation` from transformers
|
|
30
|
+
# as they are same operation.
|
|
28
31
|
"tico.quantization.wrapq.wrappers.nn.quant_silu",
|
|
29
|
-
|
|
32
|
+
## llama ##
|
|
30
33
|
"tico.quantization.wrapq.wrappers.llama.quant_attn",
|
|
31
34
|
"tico.quantization.wrapq.wrappers.llama.quant_decoder_layer",
|
|
32
35
|
"tico.quantization.wrapq.wrappers.llama.quant_mlp",
|
|
33
|
-
|
|
36
|
+
## fairseq ##
|
|
34
37
|
"tico.quantization.wrapq.wrappers.fairseq.quant_decoder_layer",
|
|
35
38
|
"tico.quantization.wrapq.wrappers.fairseq.quant_encoder",
|
|
36
39
|
"tico.quantization.wrapq.wrappers.fairseq.quant_encoder_layer",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
tico/__init__.py,sha256=
|
|
1
|
+
tico/__init__.py,sha256=zFizlBKVmXPeQuRPHlpsmWOePEoPowkPdrlRwoxPs4k,1883
|
|
2
2
|
tico/pt2_to_circle.py,sha256=gu3MD4Iqc0zMZcCZ2IT8oGbyj21CTSbT3Rgd9s2B_9A,2767
|
|
3
3
|
tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
|
|
4
4
|
tico/config/base.py,sha256=q5xMqGxTUZs4mFqt5c7i_y9U00fYgdMGl9nUqIVMlCo,1248
|
|
@@ -52,7 +52,7 @@ tico/quantization/quantizer.py,sha256=FYNiqUqoH9vz1bda0I6yuKqJi2KdIfLEBd4EgeC-_t
|
|
|
52
52
|
tico/quantization/quantizer_registry.py,sha256=MxVE1_hj1p8FjdAqkLzUhdez3Cqc-V25k6XKOcTkei0,2414
|
|
53
53
|
tico/quantization/algorithm/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
54
54
|
tico/quantization/algorithm/gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
55
|
-
tico/quantization/algorithm/gptq/gptq.py,sha256=
|
|
55
|
+
tico/quantization/algorithm/gptq/gptq.py,sha256=x7wM9_OgOrcs6WmkVCDLn2bF7YuUAR_k6vLG2l593sk,6235
|
|
56
56
|
tico/quantization/algorithm/gptq/quant.py,sha256=Rl4wAOCmlE0U09BtNCDbccaSNohRHCNLwFi3zCqZfNo,5127
|
|
57
57
|
tico/quantization/algorithm/gptq/quantizer.py,sha256=OvR9sHgosGYofwYcDhye84FBl55cNY7-UlfBt9gXbDY,11734
|
|
58
58
|
tico/quantization/algorithm/gptq/utils.py,sha256=leGKayf-xbSjVwwAGTA5RsxUKrhDiklOQdlsLifjdrs,1811
|
|
@@ -131,7 +131,7 @@ tico/quantization/wrapq/wrappers/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxAR
|
|
|
131
131
|
tico/quantization/wrapq/wrappers/ptq_wrapper.py,sha256=6zcVZ-vVhPCvFHQw6UlN7iizElrIHNkpAraeMaA0DDU,2388
|
|
132
132
|
tico/quantization/wrapq/wrappers/quant_elementwise.py,sha256=trchhUknmZTcoCwVA62uzBP_mWuCjjuZjF0jb7TZpfA,3550
|
|
133
133
|
tico/quantization/wrapq/wrappers/quant_module_base.py,sha256=SgyUlFYxDx39CAvcN2q4lsTedbEVPmetIigrllmvvD4,5915
|
|
134
|
-
tico/quantization/wrapq/wrappers/registry.py,sha256=
|
|
134
|
+
tico/quantization/wrapq/wrappers/registry.py,sha256=QJcOD9gEGB_DJowdTTqemcRDcYxQa4tHv2CDFgZDnA0,5168
|
|
135
135
|
tico/quantization/wrapq/wrappers/fairseq/__init__.py,sha256=K4R7rbxHosx9LBLk2WKlL8gFuZTYTws41TW47AsSUPM,149
|
|
136
136
|
tico/quantization/wrapq/wrappers/fairseq/decoder_export_single_step.py,sha256=d7ZieKiSbZ2ffkaLYMg2PJl1OyAxkKjB3OHKB4poxJs,9796
|
|
137
137
|
tico/quantization/wrapq/wrappers/fairseq/quant_decoder.py,sha256=JTCUDNEHYU5iOcbC_2mpuhvEoZqzTNIW3gPUZE1J7FE,17810
|
|
@@ -146,7 +146,7 @@ tico/quantization/wrapq/wrappers/llama/quant_mlp.py,sha256=I0EUJPnBOvaTnjT1Jk4N2
|
|
|
146
146
|
tico/quantization/wrapq/wrappers/nn/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
147
147
|
tico/quantization/wrapq/wrappers/nn/quant_layernorm.py,sha256=UoWWQaDqBY_bAeWRRsNl19LO331KQQLpZP9ACE-HyiU,6823
|
|
148
148
|
tico/quantization/wrapq/wrappers/nn/quant_linear.py,sha256=y3exJX_Og8HIi0VdpvX4M9m8Voq0e0ndiX8G6DZflT8,2165
|
|
149
|
-
tico/quantization/wrapq/wrappers/nn/quant_silu.py,sha256=
|
|
149
|
+
tico/quantization/wrapq/wrappers/nn/quant_silu.py,sha256=jRbM2lCFjqAqQj3Gur4eiHs1eCoNtjejMd16VBhNZt8,1901
|
|
150
150
|
tico/serialize/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
151
151
|
tico/serialize/circle_graph.py,sha256=qvyul_HULoz7B_6RFKQ8s9RjEvMgPq-ynMVkZe8aqE4,12034
|
|
152
152
|
tico/serialize/circle_mapping.py,sha256=c__AIHPi23lPugNJFolgMAKrw8j7gEeMaUQ1LAMSFnY,8542
|
|
@@ -263,9 +263,9 @@ tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
|
263
263
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
|
264
264
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
|
265
265
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
|
266
|
-
tico-0.1.0.
|
|
267
|
-
tico-0.1.0.
|
|
268
|
-
tico-0.1.0.
|
|
269
|
-
tico-0.1.0.
|
|
270
|
-
tico-0.1.0.
|
|
271
|
-
tico-0.1.0.
|
|
266
|
+
tico-0.1.0.dev251106.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
|
267
|
+
tico-0.1.0.dev251106.dist-info/METADATA,sha256=cH9ZYH9ysDRREwJcSjMV1VkLFpNjoOSxPBChSzab-A0,9730
|
|
268
|
+
tico-0.1.0.dev251106.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
269
|
+
tico-0.1.0.dev251106.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
|
|
270
|
+
tico-0.1.0.dev251106.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
|
271
|
+
tico-0.1.0.dev251106.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|