@ptrblck
although SSD() is deepcopyable, but still having problem to run QAT…, the problem is: cannot torch.save(net_int8) and it complaints:

torch.save(net_int8, model_path) #to save the entire model

File “/home/paul/pytorch/lib/python3.6/site-packages/torch/serialization.py”, line 370, in save
_legacy_save(obj, opened_file, pickle_module, pickle_protocol)
File “/home/paul/pytorch/lib/python3.6/site-packages/torch/serialization.py”, line 443, in _legacy_save
pickler.dump(obj)
AttributeError: Can’t pickle local object ‘_with_args.._PartialWrapper’

the code with problem area is:

            net.eval()
            net_int8 = torch.quantization.convert(net)
             
            #torch.save(net_int8.state_dict(), model_path)
            torch.save(net_int8, model_path) #to save the entire model


If I only save state_dict(), there is no problem. But when save the entire model, the problem show.
Further debug, finding the net was loaded and torch.save-able, but after the net.qconfig and it becomes not torch.save-able anymore:

torch.save(net,"./net_before_qconfig")
net.qconfig = torch.quantization.get_default_qat_qconfig('fbgemm')
torch.save(net,"./net_after_qconfig")


As shown above, the torch.save(net, “./net_before_qconfig”) works, but after net.qconfig, the net is not torch.save-able anymore… ;((
And having the same complaints:

torch.save(net,"./net_after_qconfig")

File “/home/paul/pytorch/lib/python3.6/site-packages/torch/serialization.py”, line 370, in save
_legacy_save(obj, opened_file, pickle_module, pickle_protocol)
File “/home/paul/pytorch/lib/python3.6/site-packages/torch/serialization.py”, line 443, in _legacy_save
pickler.dump(obj)
AttributeError: Can’t pickle local object ‘_with_args.._PartialWrapper’

Is this QAT problem? torch.save cannot save the entire model after QAT? I need the entire model saved to port to a micro processor for speed up testing. If this is QAT limitation, what would be the work around to still save the entire quantization model (not just state_dict)? Thank you again for your help!