def test_channelwise_palettization_unique_skip_op(self, compute_unit, backend, caplog):
        """Test where mode is unique and can't use nbits to represent the weight"""
        model, inputs, torch_input_values, coreml_input_values = get_test_model_and_data_complex()
        traced_model = torch.jit.trace(model, torch_input_values)
        mlmodel = ct.convert(
            traced_model,
            inputs=inputs,
            convert_to="mlprogram",
            minimum_deployment_target=backend.opset_version,
            compute_precision=ct.precision.FLOAT16
            if backend.precision == "fp16"
            else ct.precision.FLOAT32,
            compute_units=compute_unit,
        )

        config = cto.coreml.OptimizationConfig()
        global_config = cto.coreml.OpPalettizerConfig(
            mode="unique",
            granularity="per_grouped_channel",
            group_size=1,
            weight_threshold=100,
        )
        # For conv weight in the whole tensor cannot be represented by 2**8 unique values.
        conv_config = cto.coreml.OpPalettizerConfig(
            mode="unique",
            granularity="per_tensor",
            weight_threshold=100,
        )
        config.set_global(global_config)
        config.set_op_type("conv", conv_config)

        if backend.opset_version < ct.target.iOS18:
            with pytest.raises(ValueError, match=self._ERR_MSG.format("per_grouped_channel")):
                cto.coreml.palettize_weights(mlmodel, config)
            return

        mlmodel_palettized = cto.coreml.palettize_weights(mlmodel, config)
        assert any(
            [
                "Unique values in weight cannot be represented by 8 bits palettization."
                in rec.message
                for rec in caplog.records
            ]
        )
        # There is no constexpr for the conv weight.
        for conv_op in mlmodel_palettized._mil_program.find_ops(op_type="conv"):
            assert conv_op.weight.op.op_type == "const"
        # There are still constexpr ops for linear and lstm weights.
        assert len(mlmodel_palettized._mil_program.find_ops(op_type="constexpr_lut_to_dense")) == 5

        if _macos_version() >= (15, 0):
            verify_model_outputs(mlmodel, mlmodel_palettized, coreml_input_values)
Test where mode is unique and can't use nbits to represent the weight
coremltools/test/optimize/coreml/test_post_training_quantization.py