Xilinx / brevitas

Brevitas: neural network quantization in PyTorch
https://xilinx.github.io/brevitas/
Other
1.17k stars 195 forks source link

weight_bit_width quantisation #548

Open bene-w opened 1 year ago

bene-w commented 1 year ago

Hi there,

I am currently using the brevitas weight_bit_width quantisation for quantisation aware training on a convolutional SNN. Since this method outperforms my other QAT methods, I am wondering if Brevitas does some "magic" in the back besides adding the quantisation noise detached to the weight tensors during the forward pass.

Thanks a lot!

Maya7991 commented 3 months ago

Hi @bene-w , I have been working on using Brevitas for QAT of a convolutional SNN. I have some trouble understanding how to fuse the quantization of convolutional layer with SnnTorch's LIF activation function. If you have done this, it would be great help if you can answer a few questions of mine.

bene-w commented 3 months ago

Hi @Maya7991 In our work, we quantized only the weights. There we replaced the whole conv or linear layer with the quantized version, provided by Brevitas. You can find the implementation at https://github.com/RWTH-IDS/noisy-decolle under the path quantization/scalar/utils.py If you end up using pieces of the code, please feel free to cite our correlating paper https://ieeexplore.ieee.org/document/10459995 where we provide some interesting context to the work. If you have further questions, feel free to reach out again.