I am trying to use mmrazor to quantize the model, but it gives me the following error and fails -
Traceback (most recent call last):
File "tools/ptq.py", line 74, in
main()
File "tools/ptq.py", line 67, in main
runner = Runner.from_cfg(cfg)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 445, in from_cfg
runner = cls(
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 412, in init
self.model = self.build_model(model)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 819, in build_model
model = MODELS.build(model)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, args, kwargs, registry=self)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(args) # type: ignore
File "/home/ubuntu/mmrazor/mmrazor/models/algorithms/quantization/mm_architecture.py", line 90, in init
self.qmodels = self._build_qmodels(self.architecture)
File "/home/ubuntu/mmrazor/mmrazor/models/algorithms/quantization/mm_architecture.py", line 297, in _build_qmodels
observed_module = self.quantizer.prepare(
File "/home/ubuntu/mmrazor/mmrazor/models/quantizers/native_quantizer.py", line 231, in prepare
traced_graph = self.tracer.trace(model, concrete_args=concrete_args)
File "/home/ubuntu/mmrazor/mmrazor/models/task_modules/tracer/fx/custom_tracer.py", line 421, in trace
'output', (self.create_arg(fn(args)), ), {},
File "/home/ubuntu/mmdetection/mmdet/models/detectors/base.py", line 100, in forward
return self.predict(inputs, data_samples)
File "/home/ubuntu/mmdetection/mmdet/models/detectors/single_stage.py", line 110, in predict
results_list = self.bbox_head.predict(
File "/home/ubuntu/mmdetection/mmdet/models/dense_heads/base_dense_head.py", line 207, in predict
predictions = self.predict_by_feat(
File "/home/ubuntu/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py", line 60, in rtmdet_ins_headpredict_by_feat
mlvl_priors = self.prior_generator.grid_priors(
File "/home/ubuntu/mmdetection/mmdet/models/task_modules/prior_generators/point_generator.py", line 164, in grid_priors
priors = self.single_level_grid_priors(
File "/home/ubuntu/mmdeploy/mmdeploy/codebase/mmdet/models/task_modules/prior_generators/point_generator.py", line 48, in mlvl_point_generator__single_level_grid_priorstensorrt
shift_x = (torch.arange(0, feat_w, device=device) + self.offset) * stride_w
TypeError: arange() received an invalid combination of arguments - got (int, Proxy, device=Attribute), but expected one of:
(Number start, Number end, Number step, *, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
To Reproduce
The command you executed.
To reproduce run - python tools/ptq.py configs/quantization/ptq/base/ptq_tensorrt_rtmdet_s_8xb8-300e_coco_calib32xb32.py
ptq_tensorrt_rtmdet_s_8xb8-300e_coco_calib32xb32.py is as follows -
Describe the bug
I am trying to use mmrazor to quantize the model, but it gives me the following error and fails -
Traceback (most recent call last): File "tools/ptq.py", line 74, in
main()
File "tools/ptq.py", line 67, in main
runner = Runner.from_cfg(cfg)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 445, in from_cfg
runner = cls(
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 412, in init
self.model = self.build_model(model)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/runner/runner.py", line 819, in build_model
model = MODELS.build(model)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, args, kwargs, registry=self)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/ubuntu/.pyenv/versions/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(args) # type: ignore
File "/home/ubuntu/mmrazor/mmrazor/models/algorithms/quantization/mm_architecture.py", line 90, in init
self.qmodels = self._build_qmodels(self.architecture)
File "/home/ubuntu/mmrazor/mmrazor/models/algorithms/quantization/mm_architecture.py", line 297, in _build_qmodels
observed_module = self.quantizer.prepare(
File "/home/ubuntu/mmrazor/mmrazor/models/quantizers/native_quantizer.py", line 231, in prepare
traced_graph = self.tracer.trace(model, concrete_args=concrete_args)
File "/home/ubuntu/mmrazor/mmrazor/models/task_modules/tracer/fx/custom_tracer.py", line 421, in trace
'output', (self.create_arg(fn(args)), ), {},
File "/home/ubuntu/mmdetection/mmdet/models/detectors/base.py", line 100, in forward
return self.predict(inputs, data_samples)
File "/home/ubuntu/mmdetection/mmdet/models/detectors/single_stage.py", line 110, in predict
results_list = self.bbox_head.predict(
File "/home/ubuntu/mmdetection/mmdet/models/dense_heads/base_dense_head.py", line 207, in predict
predictions = self.predict_by_feat(
File "/home/ubuntu/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py", line 60, in rtmdet_ins_headpredict_by_feat
mlvl_priors = self.prior_generator.grid_priors(
File "/home/ubuntu/mmdetection/mmdet/models/task_modules/prior_generators/point_generator.py", line 164, in grid_priors
priors = self.single_level_grid_priors(
File "/home/ubuntu/mmdeploy/mmdeploy/codebase/mmdet/models/task_modules/prior_generators/point_generator.py", line 48, in mlvl_point_generator__single_level_grid_priorstensorrt
shift_x = (torch.arange(0, feat_w, device=device) + self.offset) * stride_w
TypeError: arange() received an invalid combination of arguments - got (int, Proxy, device=Attribute), but expected one of:
To Reproduce
The command you executed. To reproduce run -
python tools/ptq.py configs/quantization/ptq/base/ptq_tensorrt_rtmdet_s_8xb8-300e_coco_calib32xb32.py
ptq_tensorrt_rtmdet_s_8xb8-300e_coco_calib32xb32.py is as follows -detection_tensorrt-int8-explicit_dynamic-rtmdet.py is as follows
Additional context
Also is there a proper instructions for the same which i can refer to and for qat as well? [here]