Files
Model-Optimizer/modelopt
Gwena Cunha bdc04f174d [6056809] Fix TRT dependency in ModelOpt ONNX quantization (#1189)
### What does this PR do?

Type of change: Bug fix

Regression bug introduced by the Autotune integration into ModelOpt ONNX
quantization (https://github.com/NVIDIA/Model-Optimizer/pull/951),
making ModelOpt dependent on TensorRT in all scenarios. This PR fixes
this issue by requiring TensorRT only when `--autotune` is enabled.

### Usage

```python
$ python -m modelopt.onnx.quantization --onnx_path=${MODEL_NAME}.onnx
```

### Testing
See bug 6056809.

### Before your PR is "*Ready for review*"

Make sure you read and follow [Contributor
guidelines](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md)
and your commits are signed (`git commit -s -S`).

Make sure you read and follow the [Security Best
Practices](https://github.com/NVIDIA/Model-Optimizer/blob/main/SECURITY.md#security-coding-practices-for-contributors)
(e.g. avoiding hardcoded `trust_remote_code=True`, `torch.load(...,
weights_only=False)`, `pickle`, etc.).

- Is this change backward compatible?: ✅
- If you copied code from any other sources or added a new PIP
dependency, did you follow guidance in `CONTRIBUTING.md`: N/A
- Did you write any new necessary tests?: ✅
- Did you update
[Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?:
N/A

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Autotune dependency failures now surface as clearer runtime errors
instead of only logging warnings.

* **Chores**
* Centralized autotune presets and numeric defaults into a shared
configuration.
* Core autotune components are conditionally exposed so initialization
succeeds when optional acceleration libraries are absent.
  * Deferred autotune imports to runtime to improve failure handling.

* **Tests**
* Added a test ensuring the quantization CLI/parser initializes
correctly without optional acceleration libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: gcunhase <4861122+gcunhase@users.noreply.github.com>
2026-04-08 01:42:51 +05:30
..