pytorch/torch/ao/quantization/quantizer
Kimish Patel eb67c452c8 [Quant] Add DQ duplication pass (#107900)
Summary:
During convert step observers are first replaced by Q-DQ pair. In some
scenarios like following output DQ has a fan out.

                 ---> OP2 -> Q -> DQ
                /
OP -> Q -> DQ -
                \
                 ---> OP3 -> Q -> DQ

If either op OP2 or OP3 are configured to be quantized, then the input
is expected to quantized. In this case quantized equivalent of some
pattern, that quantizer asked to be quantized, should look like:
[DQ -> {pattern} -> Q]. However, in scenario like above where DQ node
is shared between multiple "quantized" patterns, boundary of "quantized"
pattern is not clear because DQ now belongs to multiple quantized
patterns.

This poses challenge for:
- Porting metadata: which "quantized" partition this DQ node belongs
- Quantized representation, equivalently, needs to identify
self-contained quantized pattern that is replaced by its equivalent pattern
that captures compute in the quantized precision.

Test Plan:
test_duplicate_dq_pass

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D48663147](https://our.internmc.facebook.com/intern/diff/D48663147)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/107900
Approved by: https://github.com/jerryzh168, https://github.com/andrewor14, https://github.com/leslie-fang-intel
ghstack dependencies: #107105, #107106, #107899
2023-09-02 06:20:03 +00:00
..
__init__.py [quant][pt2e] Move specific quantizer related things outside of main quant code base (#106806) (#107259) 2023-08-18 21:29:09 +00:00
composable_quantizer.py [quant][pt2e] Move specific quantizer related things outside of main quant code base (#106806) (#107259) 2023-08-18 21:29:09 +00:00
embedding_quantizer.py [quant][pt2e] Move specific quantizer related things outside of main quant code base (#106806) (#107259) 2023-08-18 21:29:09 +00:00
quantizer.py [quant][pt2e] Add support for channel in DerivedQuantizationSpec (#107833) 2023-08-24 07:45:13 +00:00
utils.py [Quant] Add DQ duplication pass (#107900) 2023-09-02 06:20:03 +00:00
x86_inductor_quantizer.py x86_inductor_quantizer switches to new graph capture API (#108214) 2023-09-01 00:43:45 +00:00
xnnpack_quantizer_utils.py [Quant] Add DQ duplication pass (#107900) 2023-09-02 06:20:03 +00:00
xnnpack_quantizer.py [Quantization] Make annotation util functions return annotated nodes (#107106) 2023-09-02 06:19:55 +00:00