Skip to content

Manually apply 4bit weight packing #7274

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

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
6 changes: 6 additions & 0 deletions backends/vulkan/_passes/int4_weight_only_quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ def _create_quantized_state_dict(
self.groupsize,
self.precision, # dtype for scales_and_zeros
)
# If the packing of 2 4-bit values into a single 8-bit value was not
# performed in the previous function call, then do it manually now.
if w_int4x8.shape == weight.shape:
w_int4x8 = (w_int4x8[::, ::2] << 4 | w_int4x8[::, 1::2]).to(
torch.uint8
)
# In the original implementation, w_int4x8 is packed via calling the
# _convert_weight_to_int4pack operator before storing the weight. However
# the Vulkan implementation does not expect the weights to be packed, so
Expand Down
Loading