[2/N] Added KDLoss based AutoQuantize - #592
Merged
realAsma merged 2 commits intoNov 25, 2025
Merged
Conversation
realAsma
requested review from
a team,
Edwardf0t1 and
ajrasane
and removed request for
a team
November 20, 2025 23:11
realAsma
requested review from
Fridah-nv,
cjluo-nv,
kevalmorabia97,
kinjalpatel27 and
mxinO
November 20, 2025 23:18
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 20, 2025 23:39
197d4d6 to
9134ca9
Compare
realAsma
force-pushed
the
asma/auto_quantize_improvements
branch
from
November 21, 2025 00:21
9ebd69f to
b7bd107
Compare
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 21, 2025 00:33
dc15dae to
48b0423
Compare
realAsma
force-pushed
the
asma/auto_quantize_improvements
branch
3 times, most recently
from
November 21, 2025 17:56
60a0f26 to
0275c61
Compare
meenchen
reviewed
Nov 21, 2025
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 21, 2025 21:22
48b0423 to
73fc080
Compare
meenchen
reviewed
Nov 24, 2025
realAsma
commented
Nov 25, 2025
realAsma
force-pushed
the
asma/auto_quantize_improvements
branch
2 times, most recently
from
November 25, 2025 20:21
6405f2b to
d08a403
Compare
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 25, 2025 20:24
46670e1 to
09d8a29
Compare
meenchen
approved these changes
Nov 25, 2025
realAsma
force-pushed
the
asma/auto_quantize_improvements
branch
from
November 25, 2025 21:44
d08a403 to
2d8ad4d
Compare
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 25, 2025 22:00
09d8a29 to
75f83da
Compare
realAsma
force-pushed
the
asma/auto_quantize_improvements
branch
from
November 25, 2025 23:17
6ab013e to
4b72089
Compare
Signed-off-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com> minor Signed-off-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com> cheery-picked final PR changes changelog updates Signed-off-by: realAsma <akuriparambi@nvidia.com> minor Signed-off-by: realAsma <akuriparambi@nvidia.com> KL Div formula fix Signed-off-by: realAsma <akuriparambi@nvidia.com>
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 25, 2025 23:18
75f83da to
1b52477
Compare
Some improvements for KLDiv Signed-off-by: realAsma <akuriparambi@nvidia.com> changelog update Signed-off-by: realAsma <akuriparambi@nvidia.com> minor Signed-off-by: realAsma <akuriparambi@nvidia.com> doc updates Signed-off-by: realAsma <akuriparambi@nvidia.com>
realAsma
force-pushed
the
asma/auto_quantize_kd_loss_sensitivity
branch
from
November 25, 2025 23:34
6e3ad6f to
0aada4e
Compare
realAsma
added a commit
that referenced
this pull request
Nov 26, 2025
…AutoQuantizeGradientSearcher; seperated quant modules and score modules (#586) ## What does this PR do? **Type of change:** Refator; Minor new feature **Overview:** ? 1. Refactored AutoQuantizeSearcher to _AutoQuantizeBaseSearcher & AutoQuantizeGradientSearcher - Prepares architecture for additional search methods. 2. seperated quant modules and score modules - separate quantization modules from scoring modules, enabling auto-quantization to measure sensitivity at parent layers (e.g., MLP output for MoE experts) rather than individual ops. 3. Also see #592 and #588 ## Testing See unittests; `tests/unit/torch/quantization/test_autoquant.py` and `tests/unit/torch/quantization/plugins/test_huggingface.py` ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: Yes - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: Not Required ## Additional Information <!-- E.g. related issue. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for score modules in quantization workflows. * Added optional naming for quantization recipes. * **Bug Fixes** * Improved quantization grouping rules documentation with clearer configuration examples. * **Refactor** * Renamed quantization module parameters for improved clarity. * Enhanced quantization search architecture for better scalability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: realAsma <akuriparambi@nvidia.com> Co-authored-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com>
inisis
pushed a commit
to inisis/TensorRT-Model-Optimizer
that referenced
this pull request
Nov 26, 2025
…AutoQuantizeGradientSearcher; seperated quant modules and score modules (NVIDIA#586) ## What does this PR do? **Type of change:** Refator; Minor new feature **Overview:** ? 1. Refactored AutoQuantizeSearcher to _AutoQuantizeBaseSearcher & AutoQuantizeGradientSearcher - Prepares architecture for additional search methods. 2. seperated quant modules and score modules - separate quantization modules from scoring modules, enabling auto-quantization to measure sensitivity at parent layers (e.g., MLP output for MoE experts) rather than individual ops. 3. Also see NVIDIA#592 and NVIDIA#588 ## Testing See unittests; `tests/unit/torch/quantization/test_autoquant.py` and `tests/unit/torch/quantization/plugins/test_huggingface.py` ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: Yes - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: Not Required ## Additional Information <!-- E.g. related issue. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for score modules in quantization workflows. * Added optional naming for quantization recipes. * **Bug Fixes** * Improved quantization grouping rules documentation with clearer configuration examples. * **Refactor** * Renamed quantization module parameters for improved clarity. * Enhanced quantization search architecture for better scalability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: realAsma <akuriparambi@nvidia.com> Co-authored-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com> Signed-off-by: inisis <desmond.yao@buaa.edu.cn>
jQizhang
pushed a commit
to jQizhang/TensorRT-Model-Optimizer
that referenced
this pull request
Nov 26, 2025
…AutoQuantizeGradientSearcher; seperated quant modules and score modules (NVIDIA#586) ## What does this PR do? **Type of change:** Refator; Minor new feature **Overview:** ? 1. Refactored AutoQuantizeSearcher to _AutoQuantizeBaseSearcher & AutoQuantizeGradientSearcher - Prepares architecture for additional search methods. 2. seperated quant modules and score modules - separate quantization modules from scoring modules, enabling auto-quantization to measure sensitivity at parent layers (e.g., MLP output for MoE experts) rather than individual ops. 3. Also see NVIDIA#592 and NVIDIA#588 ## Testing See unittests; `tests/unit/torch/quantization/test_autoquant.py` and `tests/unit/torch/quantization/plugins/test_huggingface.py` ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: Yes - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: Not Required ## Additional Information <!-- E.g. related issue. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for score modules in quantization workflows. * Added optional naming for quantization recipes. * **Bug Fixes** * Improved quantization grouping rules documentation with clearer configuration examples. * **Refactor** * Renamed quantization module parameters for improved clarity. * Enhanced quantization search architecture for better scalability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: realAsma <akuriparambi@nvidia.com> Co-authored-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com>
HexCore8
pushed a commit
to HexCore8/Model-Optimizer
that referenced
this pull request
Apr 7, 2026
…AutoQuantizeGradientSearcher; seperated quant modules and score modules (#586) ## What does this PR do? **Type of change:** Refator; Minor new feature **Overview:** ? 1. Refactored AutoQuantizeSearcher to _AutoQuantizeBaseSearcher & AutoQuantizeGradientSearcher - Prepares architecture for additional search methods. 2. seperated quant modules and score modules - separate quantization modules from scoring modules, enabling auto-quantization to measure sensitivity at parent layers (e.g., MLP output for MoE experts) rather than individual ops. 3. Also see NVIDIA/Model-Optimizer#592 and NVIDIA/Model-Optimizer#588 ## Testing See unittests; `tests/unit/torch/quantization/test_autoquant.py` and `tests/unit/torch/quantization/plugins/test_huggingface.py` ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: Yes - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: Not Required ## Additional Information <!-- E.g. related issue. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for score modules in quantization workflows. * Added optional naming for quantization recipes. * **Bug Fixes** * Improved quantization grouping rules documentation with clearer configuration examples. * **Refactor** * Renamed quantization module parameters for improved clarity. * Enhanced quantization search architecture for better scalability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: realAsma <akuriparambi@nvidia.com> Co-authored-by: Asma Kuriparambil Thekkumpate <akuriparambi@akuriparambi-mlt.client.nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Type of change: ? New Feature
Overview:
This PR extends AutoQuantize with KL Divergence Loss-based sensitivity measurement as an alternative to the existing gradient-based approach. KD Loss uses a binary searcher similar to the binary searcher in FastNAS.
AutoQuantize gradient is faster than KL Divergence based AutoQuantize. However KL Divergence does not need the model implementation to support gradient backward. In addition, AutoQuantize collected KL Divergence is useful for sensitivity analysis of the model. KL Divergence is a more direct measure of sensitivity than gradient scores.
Usage
see
tests/unit/torch/quantization/test_autoquant.pyTesting
Testes with unit tests.
Result for Qwen3 8B

Before your PR is "Ready for review"
Additional Information