diff --git a/.gitignore b/.gitignore index 92319d6f02b35..ff300dee5adb7 100644 --- a/.gitignore +++ b/.gitignore @@ -140,6 +140,7 @@ scripts/release_notes/*.json compile_commands.json *.egg-info/ docs/source/scripts/activation_images/ +docs/source/scripts/quantization_backend_configs/ ## General diff --git a/docs/Makefile b/docs/Makefile index 28d910a89b498..e536b7d35c4ac 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -15,6 +15,7 @@ help: figures: @$(PYCMD) source/scripts/build_activation_images.py + @$(PYCMD) source/scripts/build_quantization_configs.py docset: html doc2dash --name $(SPHINXPROJ) --icon $(SOURCEDIR)/_static/img/pytorch-logo-flame.png --enable-js --online-redirect-url https://pytorch.org/docs/ --force $(BUILDDIR)/html/ diff --git a/docs/source/quantization-backend-configuration.rst b/docs/source/quantization-backend-configuration.rst new file mode 100644 index 0000000000000..07fd875fa9b34 --- /dev/null +++ b/docs/source/quantization-backend-configuration.rst @@ -0,0 +1,20 @@ +Quantization Backend Configuration +---------------------------------- + +FX Graph Mode Quantization allows the user to configure various +quantization behaviors of an op in order to match the expectation +of their backend. + +In the future, this document will contain a detailed spec of +these configurations. + + +Default values for native configurations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Below is the output of the configuration for quantization of ops +in fbgemm and qnnpack (PyTorch's default quantized backends). + +Results: + +.. literalinclude:: scripts/quantization_backend_configs/default_backend_config.txt diff --git a/docs/source/quantization.rst b/docs/source/quantization.rst index f437b58b8b83b..45076d78cafae 100644 --- a/docs/source/quantization.rst +++ b/docs/source/quantization.rst @@ -489,6 +489,17 @@ and supported quantized modules and functions. torch.ao.ns._numeric_suite torch.ao.ns._numeric_suite_fx +Quantization Backend Configuration +---------------------------------- + +The :doc:`Quantization Backend Configuration ` contains documentation +on how to configure the quantization workflows for various backends. + +.. toctree:: + :hidden: + + quantization-backend-configuration + Quantized Tensors --------------------------------------- diff --git a/docs/source/scripts/build_quantization_configs.py b/docs/source/scripts/build_quantization_configs.py new file mode 100644 index 0000000000000..7e9a011e12ba3 --- /dev/null +++ b/docs/source/scripts/build_quantization_configs.py @@ -0,0 +1,23 @@ +""" +This script will generate default values of quantization configs. +These are for use in the documentation. +""" + +from torch.ao.quantization.fx.backend_config import get_native_backend_config_dict +import os.path +from pprint import pprint + + +# Create a directory for the images, if it doesn't exist +QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH = os.path.join( + os.path.realpath(os.path.join(__file__, "..")), + "quantization_backend_configs" +) + +if not os.path.exists(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH): + os.mkdir(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH) + +output_path = os.path.join(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH, "default_backend_config.txt") + +with open(output_path, "w") as f: + pprint(get_native_backend_config_dict(), stream=f)