-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example for adaptive bit width of quantizer #1156
Comments
Printing the model parameter gives me this:
|
I'll give you a quick response and I'll take a deeper look if that doesn't help you. My initial glance is that you don't want to use the bitwidth for your cost function directly*. You'll like want to scale it**, and you might benefit from using our helpers. * That shouldn't be the cause of your problem though. ** loss = task_loss + some_small_value*model.lin.quant_weight().bit_width
Can you share your training loop? Effectively, |
Another quick sanity check is to see whether the Let us know what you find out and we can take a closer look at this if it is still an issue! |
Thank you for your quick reply and your tips. |
Hello,
I am new to the topic but I already went through the documentation provided. It shows how you can adjust the bit width so it is a learnable parameter. But how do you actually update it? I have a simple network with one quantized layer and I add the bit width of this layer to the loss function to minimize it. However, it always stays the same. Can you provide a working example or correct mine:
The quantizer is used like in the documentation:
My layer:
self.lin = qnn.QuantLinear(32, 6, weight_quant=LearnedIntWeightPerChannelFloat)
and the loss:
loss = task_loss + model.lin.quant_weight().bit_width
Thank you in advance!
The text was updated successfully, but these errors were encountered: