Commit 00576e0
authored
Fix QuantizationConstraints (#4046)
### Changes
Update `QuantizationConstraints.from_config_dict` to avoid unexpected
behavior on using `from_config_dict`
### Reason for changes
https://github.com/openvinotoolkit/nncf/blob/f12f4ca93195f342825e30127b4a96ccf9d0a9e2/src/nncf/quantization/algorithms/min_max/algorithm.py#L658-L659
Overriding unexpected attributes by using QuantizationConstraints
https://github.com/openvinotoolkit/nncf/blob/f12f4ca93195f342825e30127b4a96ccf9d0a9e2/src/nncf/common/quantization/quantizer_propagation/solver.py#L1041-L1045
Before
```python
local = QuantizationConstraints(num_bits=8)
# {'num_bits': 8}
scope_constraints = QuantizationConstraints.from_config_dict({"mode": "symmetric"})
# {'num_bits': None, 'mode': 'symmetric', 'per_channel': None, 'signedness_to_force': None}
new = local.get_updated_constraints(scope_constraints)
# {'num_bits': None, 'mode': 'symmetric', 'per_channel': None, 'signedness_to_force': None}
```
After
```python
local = QuantizationConstraints(num_bits=8)
# {'num_bits': 8}
scope_constraints = QuantizationConstraints.from_config_dict({"mode": "symmetric"})
# {'mode': 'symmetric'}
new = local.get_updated_constraints(scope_constraints)
# {'num_bits': 8, 'mode': 'symmetric'}
```
### Related tickets
CVS-183279
#4002
### Tests
https://github.com/openvinotoolkit/nncf/actions/runs/24669694021
https://github.com/openvinotoolkit/nncf/actions/runs/24669719478
PTQ-8481 parent e452dcd commit 00576e0
2 files changed
Lines changed: 34 additions & 6 deletions
File tree
- src/nncf/common/quantization
- tests/openvino/native/quantization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
| |||
302 | 303 | | |
303 | 304 | | |
304 | 305 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
0 commit comments