pytorch / pytorch/tutorials

Dynamic Quantization for GPT2 model from huggingface.

Open
#1,401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: quantization question
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Hi,

Reproducibility required: PyTorch version 1.4.0

I am trying to use the torch.quantization.quantize_dynamic function to quantize the pre_trained DistilGPT2 model from Hugging-face.

As most transformer blocks in this model are made up of the nn.Conv1d modules, there occurs a problem while performing the quantization.

I understand, because the function torch.quantization.quantize_dynamic does not define a way for quantizing the nn.Conv1d layer (see the snippet below), they all just go UN-Quantized

    if qconfig_spec is None:
        if dtype == torch.qint8:
            qconfig_spec = {
                nn.Linear : default_dynamic_qconfig,
                nn.LSTM : default_dynamic_qconfig
            }

Please suggest a solution.

cc @jerryzh168 @jianyuh

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior with PyTorch 1.4.0, torch.quantization.quantize_dynamic, and the pre-trained DistilGPT2 model from Hugging Face. No repository file, test, or acceptance criteria is named, so the intended solution and definition of done would need clarification before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.