Commit b02e888
authored
Fixes #201
`get_modelike_from_algo_cfg` was typed to accept `QuantizeAlgoCfgType`
(which includes `QuantizeAlgorithmConfig` instances), but the body only
handled list / str / None / dict and raised `ValueError("Invalid config
type")` for `QuantizeAlgorithmConfig` instances. This broke the
documented pattern of passing typed config objects (`MaxCalibConfig`,
`AWQLiteCalibConfig`, etc.) via `quant_config['algorithm']`.
The fix pre-converts a `QuantizeAlgorithmConfig` instance to its
`model_dump()` dict at function entry, so the existing dict path handles
it unchanged. Two-line change; no new branch needed.
Verification: added a unit test in
`tests/unit/torch/quantization/test_mode.py` that builds a
`MaxCalibConfig`, calls `get_modelike_from_algo_cfg` on both the object
and its equivalent dict, and asserts the two paths produce the same
tuple. Also covers the list-of-object path.
Opened by OnCallBot on behalf of realAsma. Please review the diff before
merging.
cc Chenjie Luo (module owner for torch.quantization)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* `get_modelike_from_algo_cfg` now accepts configuration objects
directly alongside existing input formats.
* **Tests**
* Added regression test to verify configuration object handling works
correctly.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/NVIDIA/Model-Optimizer/pull/1528?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Signed-off-by: realAsma <akuriparambi@nvidia.com>
1 parent e2d4d73 commit b02e888
2 files changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
0 commit comments