Comments (2)
Unfortunately, resuming training with active quantization isn't really supported. The mechanism that's in there at the moment, with quantizer_metadata
as you've noticed, is designed just for the case where you want to load a quantized model and perform evaluation (in this context, the command-line argument name resume
is a bit misleading).
As it is now, what happens is that the model is quantized when the checkpoint is loaded. But then when the schedule YAML is loaded, it "quantizes" the already quantized module, the result of which is just wrong (it zeroes out the float_weight
parameter).
So even if your workaround from above lets you bypass the error you're getting, I highly doubt you're getting correct results.
At this time we weren't planning to focus on this feature. If you want to have a go at it, I'll be happy to help with any questions.
from distiller.
@guyjacob, thanks for your reply. This explains why the hack seems to work for resuming quantized weight training -- it's the sequencing. My demo is different in this respect from the sample app in this repo. It does the following in the following order (it seemed to make sense that the model shouldn't be prepared twice, and not calling prepare_model
at all causes the restore to miss the float_xxx
).
-
Create and load compression scheduler (if present in checkpoint)
if 'compression_sched' in checkpoint: compression_scheduler = distiller.CompressionScheduler(model, device=device) compression_scheduler.load_state_dict(checkpoint['compression_sched'])
-
Load quantizer metadata (if present in checkpoint), and prepare model
if 'quantizer_metadata' in checkpoint: qmd = checkpoint['quantizer_metadata'] quantizer = qmd['type'](model, **qmd['params']) quantizer.prepare_model()
-
Load model state dictionary:
model.load_state_dict(.......)
-
Fix up
requires_grad
flags per comment above:model.apply(set_grad)
-
Load optimizer from checkpoint:
if 'optimizer' in checkpoint: optimizer = Optimizer(model.parameters(), **optimizer_args) optimizer.load_state_dict(checkpoint['optimizer'])
-
Load YAML and create compression scheduler if we didn't restore one earlier and if we want to compress:
if args.compress and not compression_scheduler: compression_scheduler = distiller.config.file_config(model, optimizer, args.compress, device)
I'm not clear why load_state_dict
ignores the requires_grad
flags but I haven't tried digging too deep.
from distiller.
Related Issues (20)
- Could you provide the checkpoints for structural pruning experiments?
- checkpoints example in example jupyter-notebook download denied. HOT 1
- Support for PyTorch 1.7? HOT 3
- Can't install pyglet, even when i cloned it form github
- Higher than 8-bit Quantization not working properly!?
- yolo4 custom object detection deep compression
- Why can't I use multi-GPU training
- How can I use the distilled model in embedded device?
- Combining quantization and pruning in Distiller
- Issue running compress_classifier.py HOT 1
- Reduce the yolov3 model size of keras(.h5) or darknet(.weight)
- Quantization don't reduce the model file size
- How to train my original dataset in distiller? HOT 1
- Error running 'pip install mintapi' on Raspberry Pi
- --load-serialized will make model fail to prune HOT 1
- QAT for LSTM
- outdated requirements? HOT 2
- Sensitivity Analysis
- Does it support translation model?
- Load quantization aware model checkpoint (inference) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distiller.