Skip to content

PQBatchNorm1d.apply_final_compression stores unquantized weights #48

Description

@MartinaJoergensen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions