Closed youdutaidi closed 2 years ago
I think maybe you didn't apply the calibration step (just a few forward) for that model, like here. You may check it carefully.
I think maybe you didn't apply the calibration step (just a few forward) for that model, like here. You may check it carefully.
Thank you that I have takled the problem.
But another problem emerges. I find that the model after calibration and quantization ( in test_quant.py , after code "model.quant()", I tried to save the quantized model, but I find it is same as before quantization.
Will the model change the weights after quantization? Or only quantized during validation process but not stored in weights?
We implement our methods with FakeQuantization
, and thus the weights are "only quantized during validation process but not stored in weights".
We implement our methods with
FakeQuantization
, and thus the weights are "only quantized during validation process but not stored in weights".
Sorry but how can I store the quantized weight ? In my understanding, fakequantization is a method that stored quantized weight in fp32 format but with quantized value. But actually, the values didn't change after code "model.quant()"
Yes, all weights are stored as fp32 here.
However, after the calibration and quantization steps, you can store all weights as int8 after this line, using torch.tensor(outputs.clone().detach(), dtype=torch.int8)
or, you can convert all weights one by one, using
weight_q = CONV.quantizer.quant(CONV.weight)
saved_weight = torch.tensor(weight_q.clone().detach(), dtype=torch.int8)
I just want to test the FQVit results in Segmentation with quantized SwinTransform backbone, and I only change the code of Mlp as following:
and I didn't modify the training code from github: https://github.com/SwinTransformer/Swin-Transformer-Semantic-Segmentation
but get result:
Could you please help me where I did wrong? Thanks a lot for your kindness.