PQBatchNorm1d.apply_final_compression sets self.final_compression_done = True before reading self.weight, causing the weight copy to be a no-op. At inference the unquantized _weight (typically 1.0 init) is used instead of the quantized value.
Root cause
The weight property returns self._weight directly when final_compression_done is True. Setting it first means self._weight.data = self.weight resolves to self._weight.data = self._weight so nothing is stored.
# Current (buggy) — PQBatchNorm1d:
def apply_final_compression(self):
self.final_compression_done = True # ← too early
self._weight.data = self.weight # no-op: returns _weight directly
self._bias.data = self.bias
# PQDense does this correctly — set fcd last:
def apply_final_compression(self):
self._weight.data = self.weight # quantized value captured while fcd=False
self._bias.data = self.bias
self.final_compression_done = True
Fix: swap the ordering in PQBatchNorm1d.apply_final_compression to match PQDense.
PQBatchNorm1d.apply_final_compressionsetsself.final_compression_done = Truebefore readingself.weight, causing the weight copy to be a no-op. At inference the unquantized_weight(typically 1.0 init) is used instead of the quantized value.Root cause
The weight property returns
self._weightdirectly whenfinal_compression_doneisTrue. Setting it first meansself._weight.data = self.weightresolves toself._weight.data = self._weightso nothing is stored.Fix: swap the ordering in
PQBatchNorm1d.apply_final_compressionto matchPQDense.