fix(quantization): accept QuantizeAlgorithmConfig in get_modelike_from_algo_cfg (#201)#1528
Conversation
…m_algo_cfg (#201) Signed-off-by: realAsma <akuriparambi@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR resolves a type-hint discrepancy in ChangesQuantizeAlgorithmConfig Input Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1528 +/- ##
==========================================
- Coverage 76.75% 76.72% -0.03%
==========================================
Files 476 476
Lines 51811 51813 +2
==========================================
- Hits 39767 39756 -11
- Misses 12044 12057 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…m_algo_cfg (#201) (#1528) 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>
Fixes #201
get_modelike_from_algo_cfgwas typed to acceptQuantizeAlgoCfgType(which includesQuantizeAlgorithmConfiginstances), but the body only handled list / str / None / dict and raisedValueError("Invalid config type")forQuantizeAlgorithmConfiginstances. This broke the documented pattern of passing typed config objects (MaxCalibConfig,AWQLiteCalibConfig, etc.) viaquant_config['algorithm'].The fix pre-converts a
QuantizeAlgorithmConfiginstance to itsmodel_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.pythat builds aMaxCalibConfig, callsget_modelike_from_algo_cfgon 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)
Summary by CodeRabbit
New Features
get_modelike_from_algo_cfgnow accepts configuration objects directly alongside existing input formats.Tests