tico 0.1.0.dev250807__py3-none-any.whl → 0.1.0.dev250811__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/experimental/quantization/algorithm/gptq/quantizer.py +8 -1
- tico/experimental/quantization/config.py +2 -1
- tico/serialize/operators/adapters/__init__.py +1 -0
- tico/serialize/operators/adapters/llama_rmsnorm.py +35 -0
- tico/serialize/operators/op_rmsnorm.py +65 -0
- tico/utils/dtype.py +22 -0
- tico/utils/register_custom_op.py +23 -0
- tico/utils/signature.py +248 -0
- tico/utils/validate_args_kwargs.py +26 -0
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/METADATA +1 -1
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/RECORD +16 -12
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/LICENSE +0 -0
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/WHEEL +0 -0
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/entry_points.txt +0 -0
- {tico-0.1.0.dev250807.dist-info → tico-0.1.0.dev250811.dist-info}/top_level.txt +0 -0
tico/__init__.py
CHANGED
@@ -183,7 +183,12 @@ class GPTQQuantizer(BaseQuantizer):
|
|
183
183
|
|
184
184
|
quantizers: Dict[str, Any] = {}
|
185
185
|
for l_idx, layer in enumerate(
|
186
|
-
tqdm(
|
186
|
+
tqdm(
|
187
|
+
target_layers,
|
188
|
+
desc="Quantizing layers",
|
189
|
+
unit="layer",
|
190
|
+
disable=not gptq_conf.show_progress,
|
191
|
+
)
|
187
192
|
):
|
188
193
|
# 1) Identify quantizable submodules within the layer
|
189
194
|
full = find_layers(layer)
|
@@ -218,6 +223,7 @@ class GPTQQuantizer(BaseQuantizer):
|
|
218
223
|
desc=f"[L{l_idx}] collecting",
|
219
224
|
leave=False,
|
220
225
|
unit="batch",
|
226
|
+
disable=not gptq_conf.show_progress,
|
221
227
|
):
|
222
228
|
cache_args_batch = gather_single_batch_from_list(
|
223
229
|
self.cache_args, batch_idx
|
@@ -251,6 +257,7 @@ class GPTQQuantizer(BaseQuantizer):
|
|
251
257
|
desc=f"[L{l_idx}] re-forward",
|
252
258
|
leave=False,
|
253
259
|
unit="batch",
|
260
|
+
disable=not gptq_conf.show_progress,
|
254
261
|
):
|
255
262
|
cache_args_batch = gather_single_batch_from_list(
|
256
263
|
self.cache_args, batch_idx
|
@@ -42,8 +42,9 @@ class GPTQConfig(BaseConfig):
|
|
42
42
|
Configuration for GPTQ.
|
43
43
|
"""
|
44
44
|
|
45
|
-
def __init__(self, verbose: bool = False):
|
45
|
+
def __init__(self, verbose: bool = False, show_progress: bool = True):
|
46
46
|
self.verbose = verbose
|
47
|
+
self.show_progress = show_progress
|
47
48
|
|
48
49
|
@property
|
49
50
|
def name(self) -> str:
|
@@ -0,0 +1 @@
|
|
1
|
+
# DO NOT REMOVE THIS FILE
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
from contextlib import contextmanager
|
16
|
+
|
17
|
+
import torch
|
18
|
+
|
19
|
+
from transformers.models.llama.modeling_llama import LlamaRMSNorm
|
20
|
+
|
21
|
+
|
22
|
+
def llama_rmsnorm_forward_adapter(self: LlamaRMSNorm, hidden_states: torch.Tensor):
|
23
|
+
return torch.ops.circle_custom.rms_norm(
|
24
|
+
hidden_states, self.weight, self.variance_epsilon
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
@contextmanager
|
29
|
+
def patched_llama_rmsnorm():
|
30
|
+
orig = LlamaRMSNorm.forward
|
31
|
+
LlamaRMSNorm.forward = llama_rmsnorm_forward_adapter
|
32
|
+
try:
|
33
|
+
yield
|
34
|
+
finally:
|
35
|
+
LlamaRMSNorm.forward = orig
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
from typing import Dict, List, TYPE_CHECKING
|
16
|
+
|
17
|
+
if TYPE_CHECKING:
|
18
|
+
import torch._ops
|
19
|
+
import torch.fx
|
20
|
+
import torch
|
21
|
+
from circle_schema import circle
|
22
|
+
|
23
|
+
from tico.serialize.circle_graph import CircleSubgraph
|
24
|
+
from tico.serialize.operators.hashable_opcode import OpCode
|
25
|
+
from tico.serialize.operators.node_visitor import NodeVisitor, register_node_visitor
|
26
|
+
from tico.serialize.operators.utils import create_builtin_operator, get_op_index
|
27
|
+
from tico.utils.validate_args_kwargs import CircleRMSNormArgs
|
28
|
+
|
29
|
+
|
30
|
+
@register_node_visitor
|
31
|
+
class RMSNormVisitor(NodeVisitor):
|
32
|
+
target: List[torch._ops.OpOverload] = [
|
33
|
+
torch.ops.circle_custom.rms_norm.default,
|
34
|
+
]
|
35
|
+
|
36
|
+
def __init__(self, op_codes: Dict[OpCode, int], graph: CircleSubgraph):
|
37
|
+
super().__init__(op_codes, graph)
|
38
|
+
|
39
|
+
def define_node(
|
40
|
+
self,
|
41
|
+
node: torch.fx.Node,
|
42
|
+
) -> circle.Operator.OperatorT:
|
43
|
+
args = CircleRMSNormArgs(*node.args, **node.kwargs) # type: ignore[arg-type]
|
44
|
+
input = args.input
|
45
|
+
weight = args.weight
|
46
|
+
eps = args.eps
|
47
|
+
|
48
|
+
op_index = get_op_index(
|
49
|
+
circle.BuiltinOperator.BuiltinOperator.RMS_NORM, self._op_codes
|
50
|
+
)
|
51
|
+
|
52
|
+
inputs = [input, weight]
|
53
|
+
outputs = [node]
|
54
|
+
operator = create_builtin_operator(self.graph, op_index, inputs, outputs)
|
55
|
+
|
56
|
+
# Op-specific option
|
57
|
+
operator.builtinOptionsType = (
|
58
|
+
circle.BuiltinOptions.BuiltinOptions.RmsNormOptions
|
59
|
+
)
|
60
|
+
option = circle.RmsNormOptions.RmsNormOptionsT()
|
61
|
+
option.epsilon = eps
|
62
|
+
|
63
|
+
operator.builtinOptions = option
|
64
|
+
|
65
|
+
return operator
|
tico/utils/dtype.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import numpy as np
|
2
2
|
import torch
|
3
3
|
|
4
|
+
from circle_schema import circle
|
5
|
+
|
4
6
|
NUMPY_TO_TORCH_DTYPE_DICT = {
|
5
7
|
np.dtype("float32"): torch.float32,
|
6
8
|
np.dtype("float64"): torch.float64,
|
@@ -15,6 +17,26 @@ NUMPY_TO_TORCH_DTYPE_DICT = {
|
|
15
17
|
np.dtype("bool"): torch.bool,
|
16
18
|
}
|
17
19
|
|
20
|
+
CIRCLE_TO_TORCH_DTYPE_DICT = {
|
21
|
+
circle.TensorType.TensorType.FLOAT32: torch.float32,
|
22
|
+
circle.TensorType.TensorType.UINT8: torch.uint8,
|
23
|
+
circle.TensorType.TensorType.INT8: torch.int8,
|
24
|
+
circle.TensorType.TensorType.INT16: torch.int16,
|
25
|
+
circle.TensorType.TensorType.INT32: torch.int32,
|
26
|
+
circle.TensorType.TensorType.INT64: torch.int64,
|
27
|
+
circle.TensorType.TensorType.BOOL: torch.bool,
|
28
|
+
}
|
29
|
+
|
18
30
|
|
19
31
|
def numpy_dtype_to_torch_dtype(np_dtype: np.dtype) -> torch.dtype:
|
20
32
|
return NUMPY_TO_TORCH_DTYPE_DICT[np_dtype]
|
33
|
+
|
34
|
+
|
35
|
+
def circle_dtype_to_torch_dtype(circle_dtype: int) -> torch.dtype:
|
36
|
+
assert isinstance(circle_dtype, int)
|
37
|
+
if circle_dtype not in CIRCLE_TO_TORCH_DTYPE_DICT:
|
38
|
+
raise RuntimeError(f"Unsupported dtype {circle_dtype}")
|
39
|
+
|
40
|
+
torch_dtype = CIRCLE_TO_TORCH_DTYPE_DICT[circle_dtype]
|
41
|
+
assert torch_dtype is not None
|
42
|
+
return torch_dtype
|
tico/utils/register_custom_op.py
CHANGED
@@ -703,6 +703,28 @@ def CircleQuantizeMX():
|
|
703
703
|
return input_
|
704
704
|
|
705
705
|
|
706
|
+
def CircleRMSNorm():
|
707
|
+
@custom_op("circle_custom::rms_norm", mutates_args=())
|
708
|
+
def rms_norm(
|
709
|
+
hidden_states: torch.Tensor,
|
710
|
+
weight: Optional[torch.Tensor] = None,
|
711
|
+
eps: float = 1e-05,
|
712
|
+
) -> torch.Tensor:
|
713
|
+
input_dtype = hidden_states.dtype
|
714
|
+
hidden_states = hidden_states.to(torch.float32)
|
715
|
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
716
|
+
hidden_states = hidden_states * torch.rsqrt(variance + eps)
|
717
|
+
return weight * hidden_states.to(input_dtype)
|
718
|
+
|
719
|
+
@register_fake("circle_custom::rms_norm")
|
720
|
+
def _(
|
721
|
+
hidden_states: torch.Tensor,
|
722
|
+
weight: Optional[torch.Tensor] = None,
|
723
|
+
eps: float = 1e-05,
|
724
|
+
) -> torch.Tensor:
|
725
|
+
return hidden_states.new_empty(hidden_states.size())
|
726
|
+
|
727
|
+
|
706
728
|
# Add custom ops to the torch namespace
|
707
729
|
def RegisterOps():
|
708
730
|
CircleResizeNearestNeighbor()
|
@@ -715,3 +737,4 @@ def RegisterOps():
|
|
715
737
|
CircleAvgPool2D()
|
716
738
|
CircleInstanceNorm()
|
717
739
|
CircleQuantizeMX()
|
740
|
+
CircleRMSNorm()
|
tico/utils/signature.py
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
from typing import Sequence
|
16
|
+
|
17
|
+
import numpy as np
|
18
|
+
import torch
|
19
|
+
from circle_schema import circle
|
20
|
+
|
21
|
+
from tico.serialize.circle_mapping import to_circle_shape
|
22
|
+
from tico.utils.dtype import circle_dtype_to_torch_dtype
|
23
|
+
from tico.utils.installed_packages import is_dynamic_cache_available
|
24
|
+
|
25
|
+
|
26
|
+
def is_dynamic_cache_instance(value):
|
27
|
+
if is_dynamic_cache_available():
|
28
|
+
from transformers.cache_utils import DynamicCache
|
29
|
+
|
30
|
+
return isinstance(value, DynamicCache)
|
31
|
+
else:
|
32
|
+
return False
|
33
|
+
|
34
|
+
|
35
|
+
def flatten_and_convert_kwargs(kwargs: dict) -> dict[str, torch.Tensor]:
|
36
|
+
result = {} # type: ignore[var-annotated]
|
37
|
+
for k, v in kwargs.items():
|
38
|
+
if v is None:
|
39
|
+
continue
|
40
|
+
elif isinstance(v, (list, tuple)):
|
41
|
+
# 1. handle list
|
42
|
+
def unpack_recursive(name, value, store=None):
|
43
|
+
if store is None:
|
44
|
+
store = {}
|
45
|
+
|
46
|
+
if isinstance(value, (tuple, list)):
|
47
|
+
for i, v in enumerate(value):
|
48
|
+
# recursive call. Append index to name and explore lower level
|
49
|
+
unpack_recursive(f"{name}_{i}", v, store)
|
50
|
+
else:
|
51
|
+
# base type (scalar etc.) directly stored
|
52
|
+
store[name] = value
|
53
|
+
|
54
|
+
return store
|
55
|
+
|
56
|
+
unpack_recursive(k, v, result)
|
57
|
+
elif is_dynamic_cache_instance(v):
|
58
|
+
# 2. handle DynamicCache
|
59
|
+
for idx, cache_val in enumerate(v.key_cache):
|
60
|
+
result[f"{k}_key_cache_{idx}"] = cache_val
|
61
|
+
|
62
|
+
for idx, cache_val in enumerate(v.value_cache):
|
63
|
+
result[f"{k}_value_cache_{idx}"] = cache_val
|
64
|
+
else:
|
65
|
+
result[k] = v
|
66
|
+
|
67
|
+
# 3. Convert to tensors
|
68
|
+
for k, v in result.items():
|
69
|
+
result[k] = v if isinstance(v, torch.Tensor) else torch.tensor(v)
|
70
|
+
|
71
|
+
return result
|
72
|
+
|
73
|
+
|
74
|
+
def flatten_and_convert_args(args: Sequence) -> tuple:
|
75
|
+
result = [] # type: ignore[var-annotated]
|
76
|
+
for item in args:
|
77
|
+
if item is None:
|
78
|
+
continue
|
79
|
+
|
80
|
+
# 1. recursion on list and tuple
|
81
|
+
if isinstance(item, (list, tuple)):
|
82
|
+
result.extend(flatten_and_convert_args(item))
|
83
|
+
continue
|
84
|
+
|
85
|
+
# 2. handle DynamicCache
|
86
|
+
if is_dynamic_cache_available():
|
87
|
+
from transformers.cache_utils import DynamicCache
|
88
|
+
|
89
|
+
if isinstance(item, DynamicCache):
|
90
|
+
# NOTE The tensor order is: key_in → key_out → value_in → value_out
|
91
|
+
#
|
92
|
+
# Refer to https://github.com/huggingface/transformers/blob/3457e8e73e4f5532cc69059682b1ba4484d7e7e8/src/transformers/cache_utils.py#L557
|
93
|
+
# ```
|
94
|
+
# self.key_cache[layer_idx] = torch.cat([self.key_cache[layer_idx], key_states], dim=-2)
|
95
|
+
# self.value_cache[layer_idx] = torch.cat([self.value_cache[layer_idx], value_states], dim=-2)
|
96
|
+
# ```
|
97
|
+
result.extend(item.key_cache)
|
98
|
+
result.extend(item.value_cache)
|
99
|
+
continue
|
100
|
+
|
101
|
+
# 3. Convert to tensors
|
102
|
+
result.append(item if isinstance(item, torch.Tensor) else torch.tensor(item))
|
103
|
+
|
104
|
+
return tuple(result)
|
105
|
+
|
106
|
+
|
107
|
+
class ModelInputSpec:
|
108
|
+
@classmethod
|
109
|
+
def load(cls, circle_path):
|
110
|
+
def load(circle_path: str) -> bytes:
|
111
|
+
with open(circle_path, "rb") as f:
|
112
|
+
buf = bytes(f.read())
|
113
|
+
return buf
|
114
|
+
|
115
|
+
circle_binary = load(circle_path)
|
116
|
+
return cls(circle_binary)
|
117
|
+
|
118
|
+
def __init__(self, circle_binary):
|
119
|
+
model = circle.Model.Model.GetRootAsModel(circle_binary, 0)
|
120
|
+
assert model.SubgraphsLength() == 1, "Only one subgraph is supported"
|
121
|
+
|
122
|
+
graph = model.Subgraphs(0)
|
123
|
+
tensors = [graph.Tensors(graph.Inputs(o)) for o in range(graph.InputsLength())]
|
124
|
+
|
125
|
+
self.names = [t.Name().decode("utf-8").split("::")[-1] for t in tensors]
|
126
|
+
self.shapes = [t.ShapeAsNumpy() for t in tensors]
|
127
|
+
self.shape_signatures = list(
|
128
|
+
map(
|
129
|
+
lambda x: None if (isinstance(x, int) and x == 0) else x,
|
130
|
+
(t.ShapeSignatureAsNumpy() for t in tensors),
|
131
|
+
)
|
132
|
+
)
|
133
|
+
self.types: list[torch.dtype] = [
|
134
|
+
circle_dtype_to_torch_dtype(t.Type()) for t in tensors
|
135
|
+
]
|
136
|
+
self.name_to_idx = {name: idx for idx, name in enumerate(self.names)}
|
137
|
+
|
138
|
+
def bind(self, args, kwargs, check=True):
|
139
|
+
"""Convert args and kwargs into an ordered list according to model input order"""
|
140
|
+
inputs = []
|
141
|
+
args = flatten_and_convert_args(args)
|
142
|
+
kwargs = flatten_and_convert_kwargs(kwargs)
|
143
|
+
|
144
|
+
# 1. positional arguments
|
145
|
+
for i, val in enumerate(args):
|
146
|
+
if i >= len(self.names):
|
147
|
+
raise ValueError(f"Too many positional arguments ({i+1}).")
|
148
|
+
name = self.names[i]
|
149
|
+
if name in kwargs:
|
150
|
+
raise TypeError(
|
151
|
+
f"Got multiple values for argument '{name}' (positional and keyword)."
|
152
|
+
)
|
153
|
+
inputs.append(val)
|
154
|
+
|
155
|
+
# 2. keyword arguments
|
156
|
+
for idx in range(len(args), len(self.names)):
|
157
|
+
name = self.names[idx]
|
158
|
+
if name not in kwargs:
|
159
|
+
raise ValueError(f"Missing argument for input '{name}'.")
|
160
|
+
inputs.append(kwargs[name])
|
161
|
+
|
162
|
+
if check:
|
163
|
+
self.check_types(inputs)
|
164
|
+
self.check_shapes(inputs)
|
165
|
+
|
166
|
+
return inputs
|
167
|
+
|
168
|
+
def check_types(self, inputs):
|
169
|
+
"""Check the types of input values"""
|
170
|
+
for i, (inp, ref_type) in enumerate(zip(inputs, self.types)):
|
171
|
+
# TODO: Support more data types (np array)
|
172
|
+
assert isinstance(
|
173
|
+
inp, (torch.Tensor | int | float)
|
174
|
+
), f"Input '{self.names[i]}' type must be a torch tensor or scalar."
|
175
|
+
|
176
|
+
if isinstance(inp, torch.Tensor):
|
177
|
+
if inp.dtype != ref_type:
|
178
|
+
raise TypeError(
|
179
|
+
f"Input '{self.names[i]}' type {inp.dtype} != expected {ref_type}"
|
180
|
+
)
|
181
|
+
else:
|
182
|
+
# Scalars (int, float)
|
183
|
+
if ref_type == torch.float32:
|
184
|
+
if not isinstance(inp, (float)):
|
185
|
+
raise TypeError(
|
186
|
+
f"Input '{self.names[i]}' type {type(inp)} != expected {ref_type}"
|
187
|
+
)
|
188
|
+
elif ref_type == torch.int64:
|
189
|
+
if not isinstance(inp, (int)):
|
190
|
+
raise TypeError(
|
191
|
+
f"Input '{self.names[i]}' type {type(inp)} != expected {ref_type}"
|
192
|
+
)
|
193
|
+
else:
|
194
|
+
print(f"Unexpected ref_type: {ref_type}")
|
195
|
+
|
196
|
+
def check_shapes(self, inputs):
|
197
|
+
"""Check the shapes of input values"""
|
198
|
+
|
199
|
+
def merge(shape, shape_sig):
|
200
|
+
"""
|
201
|
+
Merge shape signature with shape
|
202
|
+
"""
|
203
|
+
from copy import deepcopy
|
204
|
+
|
205
|
+
shape_merged = deepcopy(shape)
|
206
|
+
if shape_sig is not None:
|
207
|
+
for idx, ss in enumerate(shape_sig):
|
208
|
+
if ss == -1:
|
209
|
+
shape_merged[idx] = -1
|
210
|
+
|
211
|
+
return shape_merged
|
212
|
+
|
213
|
+
for i, (inp, ref_shape, ref_shape_sig) in enumerate(
|
214
|
+
zip(inputs, self.shapes, self.shape_signatures)
|
215
|
+
):
|
216
|
+
# TODO: Support more data types (np array)
|
217
|
+
assert isinstance(
|
218
|
+
inp, (torch.Tensor | int | float)
|
219
|
+
), f"Input '{self.names[i]}' type must be a torch tensor or scalar."
|
220
|
+
|
221
|
+
if isinstance(inp, torch.Tensor): # Tensor
|
222
|
+
in_shape, in_shape_sig = to_circle_shape(inp.size())
|
223
|
+
|
224
|
+
if len(in_shape) != len(ref_shape):
|
225
|
+
raise ValueError(
|
226
|
+
f"Input '{self.names[i]}' has invalid rank {len(in_shape)}!= expected {len(ref_shape)}"
|
227
|
+
)
|
228
|
+
|
229
|
+
in_merged_shape = merge(in_shape, in_shape_sig)
|
230
|
+
ref_merged_shape = merge(ref_shape, ref_shape_sig)
|
231
|
+
for in_shp, ref_shp in zip(in_merged_shape, ref_merged_shape):
|
232
|
+
if ref_shp == -1:
|
233
|
+
continue
|
234
|
+
if in_shp == -1:
|
235
|
+
raise ValueError(
|
236
|
+
f"Input '{self.names[i]}' has unknown dimension {inp.size()} != expected shape({ref_shape}) / shape signature({ref_shape_sig}) "
|
237
|
+
)
|
238
|
+
if in_shp != ref_shp:
|
239
|
+
raise ValueError(
|
240
|
+
f"Input '{self.names[i]}' has wrong dimension {inp.size()} != expected shape({ref_shape}) / shape signature({ref_shape_sig}) "
|
241
|
+
)
|
242
|
+
elif isinstance(inp, (int, float)): # Scalar
|
243
|
+
if len(ref_shape) > 0:
|
244
|
+
raise ValueError(
|
245
|
+
f"Input '{self.names[i]}' has invalid rank {len(ref_shape)}"
|
246
|
+
)
|
247
|
+
else:
|
248
|
+
print(f"Unexpected input type: {type(inp)}")
|
@@ -171,6 +171,19 @@ class CatArgs:
|
|
171
171
|
dim: int = 0
|
172
172
|
|
173
173
|
|
174
|
+
@enforce_type
|
175
|
+
@dataclass
|
176
|
+
class CircleRMSNormArgs:
|
177
|
+
"""
|
178
|
+
This is not aten ops but custom op for RMSNorm.
|
179
|
+
circle_custom.rms_norm(Tensor input, Tensor? weight=None, float? eps=None) -> Tensor
|
180
|
+
"""
|
181
|
+
|
182
|
+
input: torch.fx.Node
|
183
|
+
weight: Optional[torch.fx.Node]
|
184
|
+
eps: Optional[float]
|
185
|
+
|
186
|
+
|
174
187
|
@enforce_type
|
175
188
|
@dataclass
|
176
189
|
class ClampArgs:
|
@@ -931,6 +944,19 @@ class ResizeNearestNeighborArgs:
|
|
931
944
|
size: List[int]
|
932
945
|
|
933
946
|
|
947
|
+
@enforce_type
|
948
|
+
@dataclass
|
949
|
+
class RMSNormArgs:
|
950
|
+
"""
|
951
|
+
rms_norm(Tensor input, SymInt[] normalized_shape, Tensor? weight=None, float? eps=None) -> Tensor
|
952
|
+
"""
|
953
|
+
|
954
|
+
input: torch.fx.Node
|
955
|
+
normalized_shape: List[int]
|
956
|
+
weight: Optional[torch.fx.Node]
|
957
|
+
eps: Optional[float]
|
958
|
+
|
959
|
+
|
934
960
|
@enforce_type
|
935
961
|
@dataclass
|
936
962
|
class RoundArgs:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tico/__init__.py,sha256=
|
1
|
+
tico/__init__.py,sha256=i6HyVzF3572_JnWulVxE-KRy80Yd4W998rViuVqVHqg,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
|
@@ -6,14 +6,14 @@ tico/config/factory.py,sha256=il0zqB6Lm5NX2LnG-TUhmiP9vVeZ_3TucJMorVZIodY,1324
|
|
6
6
|
tico/config/v1.py,sha256=O1jzpUBDwoWpLohEpI08pJNwVB-yz3ufPrQm2_XWq4Y,1108
|
7
7
|
tico/experimental/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
8
8
|
tico/experimental/quantization/__init__.py,sha256=IaJPZegVJp0P3luutBo907Kp5sOJensE1Mm-XBG_jBs,122
|
9
|
-
tico/experimental/quantization/config.py,sha256=
|
9
|
+
tico/experimental/quantization/config.py,sha256=1bCSAUI043Kbq08j59mb-K1cP2lmBMbekh8p3hNK6b8,1675
|
10
10
|
tico/experimental/quantization/public_interface.py,sha256=4-v9VXsokRG2-UUYYHd_MlbHxChqdGI5iuySyYDY_Pw,4420
|
11
11
|
tico/experimental/quantization/quantizer.py,sha256=_2pDtWFKDCuKfYF2bptOwIYsa0VFNFM1ZNgi8_OGvHM,2365
|
12
12
|
tico/experimental/quantization/algorithm/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
13
13
|
tico/experimental/quantization/algorithm/gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
14
14
|
tico/experimental/quantization/algorithm/gptq/gptq.py,sha256=Qn9b_2ki7B64DcVEY25NMkww3PdZ5EqYQQXfYhNDQ6I,5555
|
15
15
|
tico/experimental/quantization/algorithm/gptq/quant.py,sha256=Rl4wAOCmlE0U09BtNCDbccaSNohRHCNLwFi3zCqZfNo,5127
|
16
|
-
tico/experimental/quantization/algorithm/gptq/quantizer.py,sha256=
|
16
|
+
tico/experimental/quantization/algorithm/gptq/quantizer.py,sha256=_ZnSD_LBag_FVcVEniPKBmw7bNZ2iZLZ8aZnexnCgrs,11693
|
17
17
|
tico/experimental/quantization/algorithm/gptq/utils.py,sha256=leGKayf-xbSjVwwAGTA5RsxUKrhDiklOQdlsLifjdrs,1811
|
18
18
|
tico/experimental/quantization/algorithm/pt2e/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
19
19
|
tico/experimental/quantization/algorithm/pt2e/quantizer.py,sha256=mdTvsG87bo8fu0GaWqSM8iBCs-4f4EfUlVtk-Ko6M34,2546
|
@@ -166,6 +166,7 @@ tico/serialize/operators/op_relu6.py,sha256=ZWqEolfAKjOdUC1ZCg0iuu4dBhkJRxVYR2tU
|
|
166
166
|
tico/serialize/operators/op_repeat.py,sha256=VrRxD31pT3hRGH-5n6ia3PJBXh_u0GvIl1hZZYFrKTQ,4507
|
167
167
|
tico/serialize/operators/op_reshape.py,sha256=6wErQpmDX9mAmfJRCTg_cg1uOdJZqHm8Nux8dNI53Vg,2559
|
168
168
|
tico/serialize/operators/op_resize_nearest_neighbor.py,sha256=dXaAnZ5M_ko_tH-HolxNpHFXkDUQ8x45myskojP5XZE,2771
|
169
|
+
tico/serialize/operators/op_rmsnorm.py,sha256=vkJgg2YtTY9pjceTLh6gTZ-MN3EltnlEyAP5gVc5SiU,2216
|
169
170
|
tico/serialize/operators/op_round.py,sha256=pe6w_TB4xGLu0iPv4Qo0a0fIkY9DgCgXk5127TWt8pE,1837
|
170
171
|
tico/serialize/operators/op_rsqrt.py,sha256=yl2vd8InjhLPbE0vHIrEera6DVXlY9dLgO7yZZCH3RI,1837
|
171
172
|
tico/serialize/operators/op_scalar_tensor.py,sha256=vDWxi4hXwyDJJhvfMR_QrBInw_No3WeU_M4gtfZqmbo,1928
|
@@ -186,11 +187,13 @@ tico/serialize/operators/op_unsqueeze.py,sha256=ZHhfVXSWEiwb2VDYX5uhxbGQyzZjKT7C
|
|
186
187
|
tico/serialize/operators/op_view.py,sha256=xxE-GvTJ1UpcHst5KXYz3qKY-eJQvXKKrSZiA2O7E40,2593
|
187
188
|
tico/serialize/operators/op_where.py,sha256=doE81GSwygrPBm3JIfN9w7kKXxeIYKxgk0eoY22QIcg,2845
|
188
189
|
tico/serialize/operators/utils.py,sha256=lXGpEJW1h8U_-gfc6EWjvvSiq3yJ9P-v1v3EMRT_pSk,2954
|
190
|
+
tico/serialize/operators/adapters/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
191
|
+
tico/serialize/operators/adapters/llama_rmsnorm.py,sha256=6t3dhfNpR03eIjsmhymF2JKd6lCf7PvInqMf77c_BOE,1139
|
189
192
|
tico/utils/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
190
193
|
tico/utils/convert.py,sha256=GgZwZtiqFzTdszfUQO0vcX39lKjs97gYwZ-Tiw_4Bbo,13222
|
191
194
|
tico/utils/define.py,sha256=Ypgp7YffM4pgPl4Zh6TmogSn1OxGBMRw_e09qYGflZk,1467
|
192
195
|
tico/utils/diff_graph.py,sha256=_eDGGPDPYQD4b--MXX0DLoVgSt_wLfNPt47UlolLLR4,5272
|
193
|
-
tico/utils/dtype.py,sha256=
|
196
|
+
tico/utils/dtype.py,sha256=L5Qb7qgbt0eQ5frUTvHYrRtTJb1dg4-JNEopcxCNg1U,1389
|
194
197
|
tico/utils/errors.py,sha256=f3csJjgbXG9W1aHhqEcou008Aor19W57X8oT5Hx8w1M,954
|
195
198
|
tico/utils/graph.py,sha256=jD6m58m5JmN9mPfaROA9CW3406iJxmnukke00AuwRqI,9131
|
196
199
|
tico/utils/installed_packages.py,sha256=J0FTwnkCGs0MxRWoCMYAqiwH7Z0GWFDLV--x-IndSp4,1017
|
@@ -200,19 +203,20 @@ tico/utils/padding.py,sha256=qKke-dJeeLHiRaePjDS66txrGyiYuipLVQeqLYad8uk,3349
|
|
200
203
|
tico/utils/passes.py,sha256=kGmDe__5cPaO6i5EDAoXSVe6yXEoX9hAny4ROb3ZEmQ,2409
|
201
204
|
tico/utils/pytree_utils.py,sha256=jrk3N6X6LiUnBCX_gM1K9nywbVAJBVnszlTAgeIeDUc,5219
|
202
205
|
tico/utils/record_input.py,sha256=QN-8D71G_WAX3QQQ5CIwbEfFJZTQ3CvL4wCMiVddua4,3894
|
203
|
-
tico/utils/register_custom_op.py,sha256=
|
206
|
+
tico/utils/register_custom_op.py,sha256=n91UtmPedoqhkR8fBNRbk9Msq79pn9DHNHlt99l2s_w,28142
|
204
207
|
tico/utils/serialize.py,sha256=mEuusEzi82WFsz3AkowgWwxSLeo50JDxyOj6yYDQhEI,1914
|
208
|
+
tico/utils/signature.py,sha256=R2GV0alRpXEbZISqPKyxCUWbgDcsrQ2ovbVG3737IzA,9595
|
205
209
|
tico/utils/torch_compat.py,sha256=oc6PztVsXdHcQ3iaVR90wLLxrGaj6zFHWZ8K9rRS6q8,1795
|
206
210
|
tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
|
207
211
|
tico/utils/utils.py,sha256=A5p3iAAxRGDsZJh4ybp-Qo3MX3vk5RrmSY-R3rXqVeI,12976
|
208
|
-
tico/utils/validate_args_kwargs.py,sha256=
|
212
|
+
tico/utils/validate_args_kwargs.py,sha256=yikeUbYfSg2378wagEMXDlJeSRv8HKI2oxpjWarolec,27268
|
209
213
|
tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
210
214
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
211
215
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
212
216
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
213
|
-
tico-0.1.0.
|
214
|
-
tico-0.1.0.
|
215
|
-
tico-0.1.0.
|
216
|
-
tico-0.1.0.
|
217
|
-
tico-0.1.0.
|
218
|
-
tico-0.1.0.
|
217
|
+
tico-0.1.0.dev250811.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
218
|
+
tico-0.1.0.dev250811.dist-info/METADATA,sha256=p8ENvpaXfA4jwrayPNaJqjCRRBKdoGu_1Vm08SBdqpU,8450
|
219
|
+
tico-0.1.0.dev250811.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
220
|
+
tico-0.1.0.dev250811.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
|
221
|
+
tico-0.1.0.dev250811.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
222
|
+
tico-0.1.0.dev250811.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|