Skip to content

Commit

Permalink
before vectorize the for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
horheynm committed Apr 24, 2024
1 parent 803f495 commit cda1c48
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compressed_tensors/quantization/lifecycle/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ def fake_quantize(
bit_range = 2**args.num_bits
max_q = torch.tensor(bit_range / 2 - 1, device=x.device)
min_q = torch.tensor(-bit_range / 2, device=x.device)
# Q = torch.zeros_like(x)

DQ = torch.zeros_like(x)
num_groups = len(scale)
group_size = int(x.shape[1] / num_groups)

# TODO: vectorize the for loop
for i in range(num_groups):
sc = scale[i]
zp = zero_point[i]

idx = i * group_size
Q = quantize(x[:, idx : (idx + group_size)], sc, zp, min_q, max_q)
DQ[:, idx : (idx + group_size)] = dequantize(Q, sc, zp)
breakpoint()
# Q = quantize(x, scale, zero_point, min_q, max_q)

return DQ


Expand Down

0 comments on commit cda1c48

Please sign in to comment.