Skip to content

Commit

Permalink
Fixed typo in the warning from compress_weights (#2267)
Browse files Browse the repository at this point in the history
### Changes

renamed name to node_name in the warning

### Reason for changes

chatglm model support

### Related tickets

125045

### Tests

test_not_quantize_with_multiple_reduction_axes
  • Loading branch information
ljaljushkin authored Nov 15, 2023
1 parent 610e800 commit 8efd04a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def do_compression(
if isinstance(reduction_axes, tuple) and len(reduction_axes) != 1:
nncf_logger.warning(
f"Weight compression expects a single reduction axes, but given {len(reduction_axes)}. "
f"Weight shape: {const_shape}, reduction axes: {reduction_axes}, node name: {nncf_node.name}. "
"The node won't be quantized."
f"Weight shape: {const_shape}, reduction axes: {reduction_axes}, "
f"node name: {nncf_node.node_name}. The node won't be quantized."
)
continue
reduction_axis = reduction_axes[0] if isinstance(reduction_axes, tuple) else reduction_axes
Expand Down
14 changes: 14 additions & 0 deletions tests/openvino/native/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,17 @@ def _create_ov_model(self):
result.get_output_tensor(0).set_names(set(["Result"]))
model = ov.Model([result], [input_node])
return model


class GatherWithTwoReductionAxes(OVReferenceModel):
def _create_ov_model(self):
input_1 = opset.parameter([2, 3], name="Input")
convert_1 = opset.convert(input_1, destination_type="i64", name="Convert_1")

gather_2_data = opset.constant(self._rng.random((3, 2, 1)), dtype=np.float32, name="gather_2_data")
gather_2 = opset.gather(gather_2_data, convert_1, axis=0, batch_dims=0)
gather_2.set_friendly_name("Gather_2")

result = opset.result(gather_2, name="Result")
model = ov.Model([result], [input_1])
return model
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nncf.quantization.algorithms.weight_compression.openvino_backend import _reshape_weights_for_grouped_quantization
from nncf.scopes import IgnoredScope
from tests.openvino.native.common import get_openvino_version
from tests.openvino.native.models import GatherWithTwoReductionAxes
from tests.openvino.native.models import IntegerModel
from tests.openvino.native.models import SequentialMatmulModel
from tests.openvino.native.models import WeightsModel
Expand Down Expand Up @@ -202,6 +203,14 @@ def test_mixed_precision(ratio, group_size, ref_nf4_nodes):
assert op.get_element_type() == ov.Type.nf4


def test_not_quantize_with_multiple_reduction_axes():
model = GatherWithTwoReductionAxes().ov_model
compressed_model = compress_weights(model, mode=CompressWeightsMode.INT8)
for op in compressed_model.get_ordered_ops():
if op.get_type_name() == "Constant" and op.get_friendly_name() == "gather_2_data":
assert op.get_element_type() == ov.Type(np.float32)


@dataclass
class QuantErrorDesc:
weight: List[float]
Expand Down

0 comments on commit 8efd04a

Please sign in to comment.