distiller
distiller copied to clipboard
Enable resuming of Quantization Aware Training checkpoints
Added a fix for the quant-aware-train checkpoint resuming issue #185
Hi @guyjacob ,
A quick summary of my changes:
- I have modified the flow of
compress_classifier.py
to first load thecompression_scheduler
and then the checkpoint (if there's any). - After that, I've modified
QuantizationPolicy
to transform the model during theon_epoch_begin
callback instead of during the ctor. That raised issues with the flow because on some QAT an new parameter is born in the model (module.clip_val
) but it wasn't moved to the correct device, so I move the entire model to the correct device during theon_epoch_begin
callback. - Added
model.is_quantized
to indicate whether a transformation is needed. - Added
dummy_input
intomodel.quantizer_metadata
to allow easy access when loading.
Combined these and this enabled loading QAT with --resume-from
:)
Let me know what you think please.
So are there any follow-up on merging this pr?
Thank you Yun-Chen Lo
The flow is now working for Quantizer
s that don't involve adding new param groups to the optimizer. That is - it doesn't work for quantizers that implement _get_new_optimizer_params_groups()
(e.g. PACTQuantizer
). Those are still WIP.
Hi, how do I evaluate the model after quantizing using quantization aware training? I still have similar issue:
`Traceback (most recent call last):
File "compress_classifier.py", line 212, in
TypeError: init() missing 1 required positional argument: 'optimizer'`
My command line:
python3.6 compress_classifier.py --arch preact_resnet20_cifar ../../Datasets/cifar10/ --evaluate --resume-from logs/2020.08.13-151953/checkpoint.pth.tar --gpus 1 --compress=../quantization/quant_aware_train/preact_resnet20_cifar_pact.yalm