Skip to content

fix: skip round+normalize when preserve_symmetry=True (already in [-1… #215

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vector_quantize_pytorch/finite_scalar_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def quantize(self, z):
offset = torch.rand_like(bounded_z) - 0.5
bounded_z = torch.where(offset_mask, bounded_z + offset, bounded_z)

if preserve_symmetry:
return bounded_z

return round_ste(bounded_z) / half_width

def _scale_and_shift(self, zhat_normalized):
Expand Down
Loading