Skip to content

Commit 9b0266f

Browse files
committed
update github links in torchao pt2e tutorial
1 parent b963540 commit 9b0266f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/source/tutorials_source/pt2e_quantizer.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ Introduction
3232
Please see `here <https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html#motivation-of-pytorch-2-export-quantization>`__ For motivations for the new API and ``Quantizer``.
3333

3434
An existing quantizer object defined for ``XNNPACK`` is in
35-
`QNNPackQuantizer <https://github.com/pytorch/pytorch/blob/main/torch/ao/quantization/pt2e/quantizer/xnnpack_quantizer.py>`__
35+
`XNNPackQuantizer <https://github.com/pytorch/executorch/blob/752f6a729d3a2090b43ace6915086d8b4e03644f/backends/xnnpack/quantizer/xnnpack_quantizer.py>`__
3636

3737
Annotation API
3838
^^^^^^^^^^^^^^^^^^^
3939

4040
``Quantizer`` uses annotation API to convey quantization intent for different operators/patterns.
4141
Annotation API mainly consists of
42-
`QuantizationSpec <https://github.com/pytorch/pytorch/blob/1ca2e993af6fa6934fca35da6970308ce227ddc7/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L38>`__
42+
`QuantizationSpec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/quantizer.py#L40>`__
4343
and
44-
`QuantizationAnnotation <https://github.com/pytorch/pytorch/blob/07104ca99c9d297975270fb58fda786e60b49b38/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L144>`__.
44+
`QuantizationAnnotation <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/quantizer.py#L121>`__.
4545

4646
``QuantizationSpec`` is used to convey intent of how a tensor will be quantized,
4747
e.g. dtype, bitwidth, min, max values, symmetric vs. asymmetric etc.
@@ -133,7 +133,7 @@ parameters can be shared among some tensors explicitly. Two typical use cases ar
133133

134134
- Example 1: One example is for ``add`` where having both inputs sharing quantization
135135
parameters makes operator implementation much easier. Without using of
136-
`SharedQuantizationSpec <https://github.com/pytorch/pytorch/blob/1ca2e993af6fa6934fca35da6970308ce227ddc7/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L90>`__,
136+
`SharedQuantizationSpec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/quantizer.py#L97>`__,
137137
we must annotate ``add`` as example in above section 1, in which two inputs of ``add``
138138
has different quantization parameters.
139139
- Example 2: Another example is that of sharing quantization parameters between inputs and output.
@@ -211,7 +211,7 @@ as this:
211211
Another typical use case to annotate a quantized model is for tensors whose
212212
quantization parameters are known beforehand. For example, operator like ``sigmoid``, which has
213213
predefined and fixed scale/zero_point at input and output tensors.
214-
`FixedQParamsQuantizationSpec <https://github.com/pytorch/pytorch/blob/1ca2e993af6fa6934fca35da6970308ce227ddc7/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L90>`__
214+
`FixedQParamsQuantizationSpec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/quantizer.py#L76>`__
215215
is designed for this use case. To use ``FixedQParamsQuantizationSpec``, users need to pass in parameters
216216
of ``scale`` and ``zero_point`` explicitly.
217217

@@ -243,14 +243,14 @@ of ``scale`` and ``zero_point`` explicitly.
243243
Another use case is to define the constraint for tensors whose quantization parameters are derived from other tensors.
244244
For example, if we want to annotate a convolution node, and define the ``scale`` of its bias input tensor
245245
as product of the activation tensor's ``scale`` and weight tensor's ``scale``. We can use
246-
`DerivedQuantizationSpec <https://github.com/pytorch/pytorch/blob/1ca2e993af6fa6934fca35da6970308ce227ddc7/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L102>`__
246+
`DerivedQuantizationSpec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/quantizer.py#L107>`__
247247
to annotate this conv node.
248248

249249
- Step 1: Identify the original floating point pattern in the FX graph. We can use the same
250250
methods introduced in ``QuantizationSpec`` example to identify the ``convolution`` pattern.
251251
- Step 2: Define ``derive_qparams_fn`` function, it accepts list of ``ObserverOrFakeQuantize`` (
252-
`ObserverBase <https://github.com/pytorch/pytorch/blob/07104ca99c9d297975270fb58fda786e60b49b38/torch/ao/quantization/observer.py#L124>`__
253-
or `FakeQuantizeBase <https://github.com/pytorch/pytorch/blob/07104ca99c9d297975270fb58fda786e60b49b38/torch/ao/quantization/fake_quantize.py#L60>`__)
252+
`ObserverBase <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/observer.py#L157>`__
253+
or `FakeQuantizeBase <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/fake_quantize.py#L78>`__)
254254
as input. From each ``ObserverOrFakeQuantize`` object, user can get the ``scale``, ``zero point`` value.
255255
User can define its heuristic about how to derive new ``scale``, ``zero point`` value based on the
256256
quantization parameters calculated from the observer or fake quant instances.
@@ -293,13 +293,13 @@ and run a `toy example <https://gist.github.com/leslie-fang-intel/b78ed682aa9b54
293293
with ``Torchvision Resnet18``. To better understand the final example, here are the classes and utility
294294
functions that are used in the example:
295295

296-
- `QuantizationConfig <https://github.com/pytorch/pytorch/blob/73fd7235ad25ff061c087fa4bafc6e8df4d9c299/torch/ao/quantization/_pt2e/quantizer/quantizer.py#L103-L109>`__
296+
- `QuantizationConfig <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/utils.py#L21>`__
297297
consists of ``QuantizationSpec`` for activation, weight, and bias separately.
298298
- When annotating the model,
299-
`get_input_act_qspec <https://github.com/pytorch/pytorch/blob/47cfcf566ab76573452787335f10c9ca185752dc/torch/ao/quantization/_pt2e/quantizer/utils.py#L10>`__,
300-
`get_output_act_qspec <https://github.com/pytorch/pytorch/blob/47cfcf566ab76573452787335f10c9ca185752dc/torch/ao/quantization/_pt2e/quantizer/utils.py#L23>`__,
301-
`get_weight_qspec <https://github.com/pytorch/pytorch/blob/47cfcf566ab76573452787335f10c9ca185752dc/torch/ao/quantization/_pt2e/quantizer/utils.py#L36>`__, and
302-
`get_bias_qspec <https://github.com/pytorch/pytorch/blob/47cfcf566ab76573452787335f10c9ca185752dc/torch/ao/quantization/_pt2e/quantizer/utils.py#L53>`__
299+
`get_input_act_qspec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/utils.py#L48>`__,
300+
`get_output_act_qspec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/utils.py#L61>`__,
301+
`get_weight_qspec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/utils.py#L74>`__, and
302+
`get_bias_qspec <https://github.com/pytorch/ao/blob/b96354087db6d0480ebbc10d5a63a9ca49c19dfa/torchao/quantization/pt2e/quantizer/utils.py#L92>`__
303303
can be used to get the ``QuantizationSpec`` from ``QuantizationConfig`` for a specific pattern.
304304

305305
A Note on IR for PT2E Quantization Flow
@@ -378,4 +378,4 @@ Conclusion
378378
With this tutorial, we introduce the new quantization path in PyTorch 2. Users can learn about
379379
how to define a ``BackendQuantizer`` with the ``QuantizationAnnotation API`` and integrate it into the PyTorch 2 Export Quantization flow.
380380
Examples of ``QuantizationSpec``, ``SharedQuantizationSpec``, ``FixedQParamsQuantizationSpec``, and ``DerivedQuantizationSpec``
381-
are given for specific annotation use case. You can use `XNNPACKQuantizer <https://github.com/pytorch/pytorch/blob/main/torch/ao/quantization/quantizer/xnnpack_quantizer.py>`_ as an example to start implementing your own ``Quantizer``. After that please follow `this tutorial <https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html>`_ to actually quantize your model.
381+
are given for specific annotation use case. You can use `XNNPACKQuantizer <https://github.com/pytorch/executorch/blob/752f6a729d3a2090b43ace6915086d8b4e03644f/backends/xnnpack/quantizer/xnnpack_quantizer.py>`_ as an example to start implementing your own ``Quantizer``. After that please follow `this tutorial <https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html>`_ to actually quantize your model.

0 commit comments

Comments
 (0)