Skip to content

Commit

Permalink
Update aimet_torch.v2 apis to default in the docs (#3672)
Browse files Browse the repository at this point in the history
Update v2 APIs to default in docs

Signed-off-by: Hitarth Mehta <[email protected]>
  • Loading branch information
quic-hitameht authored Dec 19, 2024
1 parent 946e769 commit 5494006
Show file tree
Hide file tree
Showing 31 changed files with 259 additions and 213 deletions.
4 changes: 0 additions & 4 deletions Docs/apiref/torch/adaround.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ aimet_torch.adaround
..
# start-after
.. note::

This module is also available in the experimental :mod:`aimet_torch.v2` namespace with the same top-level API.

**Top level APIs**

.. autofunction:: aimet_torch.adaround.adaround_weight.Adaround.apply_adaround
Expand Down
96 changes: 31 additions & 65 deletions Docs/apiref/torch/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ aimet_torch API

aimet_torch.quantsim <quantsim>
aimet_torch.adaround <adaround>
aimet_torch.nn <nn>
aimet_torch.quantization <quantization>
aimet_torch.seq_mse <seq_mse>
aimet_torch.quantsim.config_utils <lpbq>
aimet_torch.manual_mixed_precision <mmp>
aimet_torch.batch_norm_fold <bnf>
aimet_torch.cross_layer_equalization <cle>
aimet_torch.model_preparer <model_preparer>
aimet_torch.mixed_precision <amp>
aimet_torch.auto_mixed_precision <amp>
aimet_torch.quant_analyzer <quant_analyzer>
aimet_torch.autoquant <autoquant>
aimet_torch.bn_reestimation <bn>
aimet_torch.visualization_tools <interactive_visualization>
aimet_torch.layer_output_utils <layer_output_generation>
aimet_torch.peft <peft_lora>
aimet_torch.compress <compress>
Expand All @@ -25,88 +30,49 @@ aimet_torch
===========

.. important::
:mod:`aimet_torch` package is upgraded to :mod:`aimet_torch.v2` with more
flexible, extensible, and PyTorch-friendly user interface!

:mod:`aimet_torch` package is planned to be upgraded to :mod:`aimet_torch.v2` with more flexible, extensible, and PyTorch-friendly user interface! In a future release, the core APIs of :mod:`aimet_torch` will be fully replaced with the equivalents in :mod:`aimet_torch.v2`.

AIMET quantization for PyTorch models provides the following functionality.
aimet_torch 2 is fully backward compatible with all the public APIs of aimet_torch 1.x.,
please see :doc:`Migrate to aimet_torch 2 <../../quantsim/torch/migration_guide>`.

- :ref:`aimet_torch.quantsim <apiref-torch-quantsim>`
- :ref:`aimet_torch.nn <apiref-torch-nn>`
- :ref:`aimet_torch.quantization <apiref-torch-quantization>`
- :ref:`aimet_torch.adaround <apiref-torch-adaround>`
- :ref:`aimet_torch.seq_mse <apiref-torch-seq-mse>`
- :ref:`aimet_torch.quantsim.config_utils <apiref-torch-lpbq>`
- :ref:`aimet_torch.batch_norm_fold <apiref-torch-bnf>`
- :ref:`aimet_torch.cross_layer_equalization <apiref-torch-cle>`
- :ref:`aimet_torch.model_preparer <apiref-torch-model-preparer>`
- :ref:`aimet_torch.mixed_precision <api-torch-amp>`
- :ref:`aimet_torch.mixed_precision <api-torch-mp>`
- :ref:`aimet_torch.quant_analyzer <apiref-torch-quant-analyzer>`
- :ref:`aimet_torch.autoquant <apiref-torch-autoquant>`
- :ref:`aimet_torch.bn_reestimation <apiref-torch-bn>`
- :ref:`aimet_torch.visualization_tools <api-torch-interactive-visualization>`
- :ref:`aimet_torch.layer_output_utils <apiref-torch-layer-output-generation>`
- :ref:`aimet_torch.peft <apiref-torch-peft-lora>`
- :ref:`aimet_torch.compress <apiref-torch-compress>`

aimet_torch.v2
aimet_torch.v1
==============

Introducing :mod:`aimet_torch.v2`, a future version of :mod:`aimet_torch` with more powerful
quantization features and PyTorch-friendly user interface!

What's New
----------

These are some of the powerful new features and interfaces supported in :mod:`aimet_torch.v2`

- Blockwise quantization (BQ)
- Low power blockwise quantization (LPBQ)
- Dispatching custom quantized kernels

Backwards Compatibility
-----------------------

Good news! :mod:`aimet_torch.v2` is carefully designed to be fully backwards-compatible with all
previous public APIs of :mod:`aimet_torch`. All you need is drop-in replacement of import statements
from :mod:`aimet_torch` to :mod:`aimet_torch.v2` as below!

.. code-block:: diff
-from aimet_torch.quantsim import QuantizationSimModel
+from aimet_torch.v2.quantsim import QuantizationSimModel
-from aimet_torch.adaround.adaround_weight import Adaround, AdaroundParameters
+from aimet_torch.v2.adaround import Adaround, AdaroundParameters
-from aimet_torch.seq_mse import apply_seq_mse
+from aimet_torch.v2.seq_mse import apply_seq_mse
-from aimet_torch.quant_analyzer import QuantAnalyzer
+from aimet_torch.v2.quant_analyzer import QuantAnalyzer
All the other APIs that didn't changed in or are orthogonal with :mod:`aimet_torch.v2` will be
still accessible via :mod:`aimet_torch` namespace as before.
If you still prefer to use aimet_torch 1.x, your imports should originate from the :mod:`aimet_torch.v1`
namespace.

.. toctree::
:hidden:

aimet_torch.v2 migration guide <v2/migration_guide>
aimet_torch.v2.nn <v2/nn>
aimet_torch.v2.quantization <v2/quantization>
aimet_torch.v2.adaround <v2/adaround>
aimet_torch.v2.seq_mse <v2/seq_mse>
aimet_torch.v2.quantsim.config_utils <v2/lpbq>
aimet_torch.v2.mixed_precision <v2/mmp>
aimet_torch.v2.quant_analyzer <v2/quant_analyzer>
aimet_torch.v2.visualization_tools <v2/interactive_visualization>

For more detailed information about how to migrate to :mod:`aimet_torch.v2`,
see :ref:`aimet_torch.v2 migration guide <torch-migration-guide>`

AIMET core APIs for PyTorch framework.

- :ref:`aimet_torch.v2.quantsim <apiref-torch-v2-quantsim>`
- :ref:`aimet_torch.v2.nn <apiref-torch-nn>`
- :ref:`aimet_torch.v2.quantization <apiref-torch-quantization>`
- :ref:`aimet_torch.v2.adaround <apiref-torch-v2-adaround>`
- :ref:`aimet_torch.v2.seq_mse <apiref-torch-v2-seq-mse>`
- :ref:`aimet_torch.v2.quantsim.config_utils <apiref-torch-v2-lpbq>`
- :ref:`aimet_torch.v2.mixed_precision <api-torch-v2-mmp>`
- :ref:`aimet_torch.v2.quant_analyzer <apiref-torch-v2-quant-analyzer>`
- :ref:`aimet_torch.v2.visualization_tools <api-torch-v2-interactive-visualization>`
aimet_torch.v1.quantsim <v1/quantsim>
aimet_torch.v1.adaround <v1/adaround>
aimet_torch.v1.seq_mse <v1/seq_mse>
aimet_torch.v1.quant_analyzer <v1/quant_analyzer>
aimet_torch.v1.autoquant <v1/autoquant>
aimet_torch.v1.amp <v1/amp>

- :ref:`aimet_torch.v1.quantsim <apiref-torch-v1-quantsim>`
- :ref:`aimet_torch.v1.adaround <apiref-torch-v1-adaround>`
- :ref:`aimet_torch.v1.seq_mse <apiref-torch-v1-seq-mse>`
- :ref:`aimet_torch.v1.quant_analyzer <apiref-torch-v1-quant-analyzer>`
- :ref:`aimet_torch.v1.autoquant <apiref-torch-v1-autoquant>`
- :ref:`aimet_torch.v1.amp <apiref-torch-v1-amp>`
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
.. _api-torch-v2-interactive-visualization:
.. _api-torch-interactive-visualization:

##################################
aimet_torch.v2.visualization_tools
##################################
###############################
aimet_torch.visualization_tools
###############################

..
# start-after

.. warning::
This feature is under heavy development and API changes may occur without notice in future versions.

Expand Down
8 changes: 4 additions & 4 deletions Docs/apiref/torch/v2/lpbq.rst → Docs/apiref/torch/lpbq.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _apiref-torch-v2-lpbq:
.. _apiref-torch-lpbq:

####################################
aimet_torch.v2.quantsim.config_utils
####################################
#################################
aimet_torch.quantsim.config_utils
#################################

..
# start-after
Expand Down
46 changes: 46 additions & 0 deletions Docs/apiref/torch/mp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. _api-torch-mp:

===========================
aimet_torch.mixed_precision
===========================

..
# start-after mmp
**Top-level API for Manual mixed precision**

.. autoclass:: aimet_torch.v2.mixed_precision.MixedPrecisionConfigurator
:members:
:member-order: bysource

..
# end-before mmp
..
# start-after amp
**Top-level API for Automatic mixed precision**

.. autofunction:: aimet_torch.mixed_precision.choose_mixed_precision

.. note::
To enable phase-3 set the attribute GreedyMixedPrecisionAlgo.ENABLE_CONVERT_OP_REDUCTION = True

Currently only two candidates are supported - ((8,int), (8,int)) & ((16,int), (8,int))

**Quantizer Groups definition**

.. autoclass:: aimet_torch.amp.quantizer_groups.QuantizerGroup
:members:

**CallbackFunc Definition**

.. autoclass:: aimet_common.defs.CallbackFunc
:members:

.. autoclass:: aimet_torch.amp.mixed_precision_algo.EvalCallbackFactory
:members:

..
# end-before amp
6 changes: 3 additions & 3 deletions Docs/apiref/torch/v2/nn.rst → Docs/apiref/torch/nn.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _apiref-torch-nn:

#################
aimet_torch.v2.nn
#################
##############
aimet_torch.nn
##############

.. currentmodule:: aimet_torch.v2.nn

Expand Down
2 changes: 1 addition & 1 deletion Docs/apiref/torch/peft_lora.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ aimet_torch.peft

This document provides steps for integrating LoRA adapters with AIMET Quantization flow. LoRA adapters
are used to enhance the efficiency of fine-tuning large models with reduced memory usage. We will use
:ref:`PEFT <https://huggingface.co/docs/peft/main/en/package_reference/peft_model>` library
`PEFT <https://huggingface.co/docs/peft/main/en/package_reference/peft_model>`_ library
from HuggingFace to instantiate our model and add adapters to it.

By integrating adapters with AIMET quantization, we can perform similar functionalities as present in PEFT,
Expand Down
2 changes: 1 addition & 1 deletion Docs/apiref/torch/quant_analyzer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ QuantAnalyzer utility of your interest and pass the same object to it.

.. automethod:: aimet_torch.quant_analyzer.QuantAnalyzer.export_per_layer_stats_histogram

.. automethod:: aimet_torch.v1.quant_analyzer.QuantAnalyzer.export_per_layer_mse_loss
.. automethod:: aimet_torch.quant_analyzer.QuantAnalyzer.export_per_layer_mse_loss

..
# end-before
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _apiref-torch-quantization:

###########################
aimet_torch.v2.quantization
###########################
########################
aimet_torch.quantization
########################

.. currentmodule:: aimet_torch.v2.quantization

Expand Down
7 changes: 0 additions & 7 deletions Docs/apiref/torch/quantsim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ aimet_torch.quantsim
..
# start-after
.. note::

This module is also available in the experimental :mod:`aimet_torch.v2` namespace with the same top-level API.

.. autoclass:: aimet_torch.quantsim.QuantizationSimModel

**The following API can be used to Compute encodings for calibration:**
Expand All @@ -27,9 +23,6 @@ aimet_torch.quantsim

.. automethod:: aimet_torch.quantsim.QuantizationSimModel.export

Enum Definition
===============

**Quant Scheme Enum**

.. autoclass:: aimet_common.defs.QuantScheme
Expand Down
5 changes: 0 additions & 5 deletions Docs/apiref/torch/seq_mse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ aimet_torch.seq_mse
..
# start-after
.. note::

This module is also available in the experimental :mod:`aimet_torch.v2` namespace with the same top-level API.

**Top level APIs**

.. autofunction:: aimet_torch.seq_mse.apply_seq_mse
Expand All @@ -22,4 +18,3 @@ aimet_torch.seq_mse

..
# end-before
24 changes: 24 additions & 0 deletions Docs/apiref/torch/v1/adaround.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. _apiref-torch-v1-adaround:

#######################
aimet_torch.v1.adaround
#######################

..
# start-after
.. note::
This module is also available in the default :mod:`aimet_torch` namespace with
the same top-level API.

**Top level APIs**

.. autofunction:: aimet_torch.v1.adaround.adaround_weight.Adaround.apply_adaround

**Adaround parameters**

.. autoclass:: aimet_torch.v1.adaround.adaround_weight.AdaroundParameters
:members:

..
# end-before
12 changes: 8 additions & 4 deletions Docs/apiref/torch/amp.rst → Docs/apiref/torch/v1/amp.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
.. _api-torch-amp:
.. _apiref-torch-v1-amp:

===========================
aimet_torch.mixed_precision
===========================
==============================
aimet_torch.v1.mixed_precision
==============================

..
# start-after
.. note::
This module is also available in the default :mod:`aimet_torch` namespace with
the same top-level API.

**Top-level API**

.. autofunction:: aimet_torch.v1.mixed_precision.choose_mixed_precision
Expand Down
22 changes: 22 additions & 0 deletions Docs/apiref/torch/v1/autoquant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. _apiref-torch-v1-autoquant:

#########################
aimet_torch.v1.auto_quant
#########################

..
# start-after
.. note::
This module is also available in the default :mod:`aimet_torch` namespace with
the same top-level API.

**Top-level API**

.. autoclass:: aimet_torch.v1.auto_quant.AutoQuantWithAutoMixedPrecision
:members:
:member-order: bysource
:no-index:

..
# end-before
Loading

0 comments on commit 5494006

Please sign in to comment.