Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fx quant: do not insert observers at quantized inputs #49239

Closed
wants to merge 4 commits into from

Commits on Dec 11, 2020

  1. fx quant: do not insert observers at quantized inputs

    Summary:
    
    Context: the existing implementation of `quantized_input_idxs` is convert-only.
    Therefore, observers are inserted between the input and the first
    quantized node.  This is a problem during QAT, because the initial
    input is a fake_quant, and it starts with scale=1 and zp=0.  This does
    not match the quantization parameters of the graph input, which can
    lead to incorrect numerics.
    
    Fix: do not insert observer for a quantized input.
    
    Test Plan:
    
    ```
    python test/test_quantization.py TestQuantizeFx
    ```
    
    Reviewers:
    
    Subscribers:
    
    Tasks:
    
    Tags:
    
    [ghstack-poisoned]
    vkuzo committed Dec 11, 2020
    Configuration menu
    Copy the full SHA
    9b73b2d View commit details
    Browse the repository at this point in the history

Commits on Dec 15, 2020

  1. Update on "fx quant: do not insert observers at quantized inputs"

    Summary:
    
    Context: the existing implementation of `quantized_input_idxs` is convert-only.
    Therefore, observers are inserted between the input and the first
    quantized node.  This is a problem during QAT, because the initial
    input is a fake_quant, and it starts with scale=1 and zp=0.  This does
    not match the quantization parameters of the graph input, which can
    lead to incorrect numerics.
    
    Fix: do not insert observer for a quantized input.
    
    Test Plan:
    
    ```
    python test/test_quantization.py TestQuantizeFx
    ```
    
    Reviewers:
    
    Subscribers:
    
    Tasks:
    
    Tags:
    
    Differential Revision: [D25499486](https://our.internmc.facebook.com/intern/diff/D25499486)
    
    [ghstack-poisoned]
    vkuzo committed Dec 15, 2020
    Configuration menu
    Copy the full SHA
    4a56b48 View commit details
    Browse the repository at this point in the history
  2. comments on "fx quant: do not insert observers at quantized inputs"

    Summary:
    
    Context: the existing implementation of `quantized_input_idxs` is convert-only.
    Therefore, observers are inserted between the input and the first
    quantized node.  This is a problem during QAT, because the initial
    input is a fake_quant, and it starts with scale=1 and zp=0.  This does
    not match the quantization parameters of the graph input, which can
    lead to incorrect numerics.
    
    Fix: do not insert observer for a quantized input.
    
    Test Plan:
    
    ```
    python test/test_quantization.py TestQuantizeFx
    ```
    
    Reviewers:
    
    Subscribers:
    
    Tasks:
    
    Tags:
    
    Differential Revision: [D25499486](https://our.internmc.facebook.com/intern/diff/D25499486)
    
    [ghstack-poisoned]
    vkuzo committed Dec 15, 2020
    Configuration menu
    Copy the full SHA
    dd287e2 View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2020

  1. rebase on "fx quant: do not insert observers at quantized inputs"

    Summary:
    
    Context: the existing implementation of `quantized_input_idxs` is convert-only.
    Therefore, observers are inserted between the input and the first
    quantized node.  This is a problem during QAT, because the initial
    input is a fake_quant, and it starts with scale=1 and zp=0.  This does
    not match the quantization parameters of the graph input, which can
    lead to incorrect numerics.
    
    Fix: do not insert observer for a quantized input.
    
    Test Plan:
    
    ```
    python test/test_quantization.py TestQuantizeFx
    ```
    
    Reviewers:
    
    Subscribers:
    
    Tasks:
    
    Tags:
    
    Differential Revision: [D25499486](https://our.internmc.facebook.com/intern/diff/D25499486)
    
    [ghstack-poisoned]
    vkuzo committed Dec 16, 2020
    Configuration menu
    Copy the full SHA
    bd25bc0 View commit details
    Browse the repository at this point in the history