You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for node in model.graph.nodes:
if node.op == "get_attr":
if prefix:
sub_name = prefix + "--" + node.target
else:
sub_name = node.target
if not hasattr(model, node.target):
continue
if "scale" in node.target: #### This condition is not suitable
tune_cfg["get_attr"][sub_name] = float(getattr(model, node.target))
elif "zero_point" in node.target:
tune_cfg["get_attr"][sub_name] = int(getattr(model, node.target))
else:
pass
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/utils/utility.py", line 347, in fi
res = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 3658, in quantize
self._get_scale_zeropoint(q_model._model, q_model.q_config)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4217, in _get_scale_zeropoint
self._get_sub_module_scale_zeropoint(model, tune_cfg)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4199, in _get_sub_module_scale_zeropoint
self._get_sub_module_scale_zeropoint(module, tune_cfg, op_name)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4199, in _get_sub_module_scale_zeropoint
self._get_sub_module_scale_zeropoint(module, tune_cfg, op_name)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4199, in _get_sub_module_scale_zeropoint
self._get_sub_module_scale_zeropoint(module, tune_cfg, op_name)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4197, in _get_sub_module_scale_zeropoint
self._get_module_scale_zeropoint(module, tune_cfg, op_name)
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/neural_compressor/adaptor/pytorch.py", line 4175, in _get_module_scale_zeropoint
tune_cfg["get_attr"][sub_name] = float(getattr(model, node.target))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: only one element tensors can be converted to Python scalars
When I check the string "node.target" and the tensor value, it treats the layer_scale like a scale of quantization, as follows.
If I define a parameter with the same name as "layer_scale" in the pytorch nn.Module, as shown in the following code, a ValueError occurs.
In "adaptor/pytorch" Line 4174
When I check the string "node.target" and the tensor value, it treats the layer_scale like a scale of quantization, as follows.
Modifying the conditional statement as below fixes the problem, but it doesn't seem to be a perfect way.
The text was updated successfully, but these errors were encountered: