Skip to content

Commit 99160d2

Browse files
Lee, Kyunggeunquic-kyunggeu
authored andcommitted
Promote aimet_torch.onnx.export to production API
Signed-off-by: Kyunggeun Lee <quic_kyunggeu@quicinc.com> Co-authored-by: Kyunggeun Lee <quic_kyunggeu@quicinc.com>
1 parent e5cbd81 commit 99160d2

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

Docs/apiref/torch/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ AIMET quantization for PyTorch models provides the following functionality.
4949
- :ref:`aimet_torch.quantsim <apiref-torch-quantsim>`
5050
- :ref:`aimet_torch.nn <apiref-torch-nn>`
5151
- :ref:`aimet_torch.quantization <apiref-torch-quantization>`
52-
- :ref:`aimet_torch.onnx (beta) <apiref-torch-onnx>`
52+
- :ref:`aimet_torch.onnx <apiref-torch-onnx>`
5353
- :ref:`aimet_torch.adaround <apiref-torch-adaround>`
5454
- :ref:`aimet_torch.seq_mse <apiref-torch-seq-mse>`
5555
- :ref:`aimet_torch.experimental.adascale <apiref-torch-adascale>`

Docs/apiref/torch/onnx.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _apiref-torch-onnx:
22

3-
##############################
4-
aimet_torch.onnx.export (beta)
5-
##############################
3+
#######################
4+
aimet_torch.onnx.export
5+
#######################
66

77
.. autofunction:: aimet_torch.onnx.export

TrainingExtensions/torch/src/python/aimet_torch/onnx.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def export(
9999
100100
101101
.. note::
102-
Unlike `torch.onnx.export()`, this function allows up to opset 21.
103-
to support 4/16-bit quantization only available in opset 21.
104-
However, exporting to opset 21 is a beta feature and not fully stable yet.
105-
For robustness, opset 20 or lower is recommended whenever possible.
102+
For robustness, onnx >=1.19 is highly recommended with this API,
103+
especially when exporting large models (>2GB).
104+
This is due to a known bug in onnx <1.19 version converter.
105+
For more information, see https://github.com/onnx/onnx/issues/6529
106106
107107
.. note::
108108
Dynamo-based export (`dynamo=True`) is not supported yet

TrainingExtensions/torch/test/python/v2/experimental/test_onnx.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,17 +1208,14 @@ def large_model():
12081208
)
12091209

12101210

1211+
@pytest.fixture
1212+
def tmp_path():
1213+
with tempfile.TemporaryDirectory() as tmpdir:
1214+
yield pathlib.Path(tmpdir).resolve()
1215+
1216+
12111217
@torch.no_grad()
1212-
@pytest.mark.parametrize(
1213-
"opset_version",
1214-
[
1215-
19,
1216-
# NOTE: Currently fails because onnx version converter
1217-
# has a bug with large models. This bug is expected to be fixed in onnx 1.19.
1218-
# TODO (kyunggeu): Uncomment this when onnx 1.19 is released
1219-
# 21, TODO: Not supported yet
1220-
],
1221-
)
1218+
@pytest.mark.parametrize("opset_version", [19, 21])
12221219
@pytest.mark.parametrize("prequantize_constants", [False, True])
12231220
def test_export_large_model(
12241221
large_model: torch.nn.Module,

0 commit comments

Comments
 (0)