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

Add DETR Example #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jiang-Stan
Copy link
Collaborator

@Jiang-Stan Jiang-Stan commented Sep 2, 2022

DETR model from: https://github.com/facebookresearch/detr

bit weight observer feature observer mAP AP50 AP75 remarks
float - - 0.421 0.623 0.443 baseline
8w8f minmax minmax 0.280 0.519 0.260
8w8f minmax minmax 0.355 0.574 0.363 aciq laplace observer for last 2 bbox embed layer weights
8w8f minmax minmax 0.358 0.576 0.365 float weight
8w8f minmax minmax 0.415 0.621 0.437 aciq laplace observer for last 2 bbox embed layer weights, float feature
8w8f minmax minmax 0.408 0.614 0.430 aciq laplace observer for last 2 bbox embed layer weights, transformer skipped for testing
8w8f minmax mse 0.386 0.595 0.400 aciq laplace observer for last 2 bbox embed layer weights
8w8f minmax mse 0.392 0.602 0.409 aciq laplace observer for last 2 bbox embed layer weights, all bmm input as float

Modifications to original model:

  • dim_t as a Parameter. For torch.fx doesn't support .to(device) in forward function. (Details)
  • Tensor[None] replaced by Tensor.unsqueeze. Unrecognized pattern. (Details)
  • Explicitly define type convertion. (Details)
  • Type convertion defined before operation. (Details)
  • remove mask-related parts in model, only batch 1 supported for inference.

@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch 4 times, most recently from cf37a4b to 9eafb44 Compare September 9, 2022 07:07
@Jiang-Stan Jiang-Stan changed the title WIP: Add DETR PTQ Example WIP: Add DETR Example Sep 20, 2022
@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch from 9eafb44 to 9768dfc Compare October 11, 2022 04:28
@Jiang-Stan Jiang-Stan changed the title WIP: Add DETR Example Add DETR Example Oct 11, 2022
@Jiang-Stan Jiang-Stan requested a review from PeiqinSun October 11, 2022 07:28
@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch 2 times, most recently from 9b211e5 to 2ae66e8 Compare October 18, 2022 09:07
@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch 2 times, most recently from 321ff8e to 64c9260 Compare November 9, 2022 08:55

import util.misc as utils
from datasets.coco_eval import CocoEvaluator
from datasets.panoptic_eval import PanopticEvaluator
Copy link
Member

@PeiqinSun PeiqinSun Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are datasets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.path.append("./detr") is added to main.py, so datasets used here is detr.datasets

@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch 2 times, most recently from 13717ca to b022b39 Compare November 24, 2022 10:02
@Jiang-Stan Jiang-Stan changed the title Add DETR Example Add DETR PTQ Example Nov 24, 2022
@@ -202,3 +198,97 @@ def forward(self, x_in):
x_in = self.input_quantizer(x_in)
out = F.hardsigmoid(x_in, inplace=self.inplace)
return out

@register_qmodule(sources=[nn.MultiheadAttention])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You should build a new file to describe the QMHSA.
  2. the module name -- transformer.py

return attn_output, attn_output_weights

def prepare_input_quantizer(self, node, model):
# only qkv should be quantized.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matmul is not quant in here?

WIP

WIP

WIP

Can test version

Can test version

modify for dump onnx

ready version

ready version

ready version

ready version

ready version

ready version

update_readme

add detr qat example

fix bugs for qat

update readme

reformat dirs

reformat dirs

reformat dirs

update readme

rectify sparsebit

move qat to another branch

modify aciq observer and use aciq laplace for last 2 detr bbox embed weights

update readme

modifications for hugging DETR

simplify MR

simplify MR

add detr as submodule

detr as submodule

detr as submodule

detr as submodule

detr as submodule

rm qdropout

rm redundant

clean-up

rebase modifications

rebase modifications

rebase modifications

not finished yet

not finished yet

wrong version

write but low_acc version

finished version

finished version

finished version
debugging

support detr qat

remove print
@Jiang-Stan Jiang-Stan force-pushed the support_detr_example branch from e0417a3 to d1db231 Compare December 7, 2022 02:41
@Jiang-Stan Jiang-Stan changed the title Add DETR PTQ Example Add DETR Example Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants