This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CODECOMPOSER: Quantization Aware Training (QAT)

Part Number: CODECOMPOSER

Tool/software:

Hello, I have been through routine of links, and use semantic segmentation model: fpn_aspp_regnetx1p6gf_edgeailite trains the cityspaces dataset and obtains the model_best.pth model.
​However, in the Quantization Aware Training (QAT), I have carried out the following configuration according to the QAT.md tutorial:

Fullscreen
1
2
3
4
5
6
7
8
9
is_cuda = next(model.parameters()).is_cuda
example_inputs = create_rand_inputs(args, is_cuda=is_cuda)
if 'training' in args.phase:
model = edgeai_torchmodelopt.xmodelopt.quantization.v2.QATFxModule(model, example_inputs=example_inputs, total_epochs=args.epochs)
elif 'calibration' in args.phase:
model = edgeai_torchmodelopt.xmodelopt.quantization.v2.QATFxModule(model)
elif 'validation' in args.phase:
# Note: bias_calibration is not emabled
model = edgeai_torchmodelopt.xmodelopt.quantization.v2.QATFxModule(model, total_epochs=args.epochs)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

However, I got the following error:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Traceback (most recent call last):
File "/home/xcb/zjb/algorithm/edgeai-torchvision/./references/edgeailite/main/pixel2pixel/train_segmentation_main.py", line 290, in <module>
run(args)
File "/home/xcb/zjb/algorithm/edgeai-torchvision/./references/edgeailite/main/pixel2pixel/train_segmentation_main.py", line 285, in run
main(arguments)
File "/home/xcb/zjb/algorithm/edgeai-torchvision/./references/edgeailite/main/pixel2pixel/train_segmentation_main.py", line 148, in main
train_pixel2pixel.main(arguemnts)
File "/home/xcb/zjb/algorithm/edgeai-torchvision/references/edgeailite/edgeai_xvision/xengine/train_pixel2pixel.py", line 450, in main
model = edgeai_torchmodelopt.xmodelopt.quantization.v2.QATFxModule(model, example_inputs=example_inputs, total_epochs=args.epochs)
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/edgeai_torchmodelopt/xmodelopt/quantization/v2/quant_fx.py", line 37, in __init__
super().__init__(*args, is_qat=True, backend=backend, **kwargs)
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/edgeai_torchmodelopt/xmodelopt/quantization/v2/quant_fx_base.py", line 79, in __init__
model = quantize_fx.prepare_qat_fx(model, qconfig_mapping, example_inputs)
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/torch/ao/quantization/quantize_fx.py", line 515, in prepare_qat_fx
return _prepare_fx(
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/torch/ao/quantization/quantize_fx.py", line 162, in _prepare_fx
graph_module = GraphModule(model, tracer.trace(model))
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/torch/fx/_symbolic_trace.py", line 739, in trace
(self.create_arg(fn(*args)),),
File "/home/xcb/anaconda3/envs/edgeai/lib/python3.10/site-packages/edgeai_torchmodelopt/xnn/utils/amp.py", line 45, in conditional_fp16
return func(self, *args, **kwargs)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I've gone through the tutorial and I've removed example_inputs=example_inputs, and I still get the above error, should I add some other configuration?

Looking forward to your reply!Thanks!