Skip to content
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

Fix (gptq): fix for depthwise act_order #688

Merged
merged 1 commit into from
Jul 28, 2023
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
10 changes: 6 additions & 4 deletions src/brevitas/graph/gptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,18 @@ def single_layer_update(self, percdamp=.01):
if self.groups > 1:
# In case of depthwise convs, each weight matrix interacts with only
# part of the input values, thus with only one of the hessian matrix
for ii in range(self.groups):
for ii, perm in enumerate(permutation_list):
weight_block[ii, i:] -= error[ii] * h_inv_block[ii, i, i:]
# We need to update the original weights
weight[ii, perm[i1:i2][i:]] = weight_block[ii, i:].to(dtype)
else:
perm = permutation_list[0]
weight_block[:, i:] -= error.unsqueeze(1).matmul(
h_inv_block[0, i, i:].unsqueeze(0))
# We need to update the original weights
weight[:, perm[i1:i2][i:]] = weight_block[:, i:].to(dtype)
error_block[:, i] = error

# We need to update the original weights
weight[:, perm[i1:i2][i:]] = weight_block[:, i:].to(dtype)

if self.groups > 1:
# In case of depthwise convs, each weight matrix interacts with only
# part of the input values, thus with only one of the hessian matrix
Expand Down