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

[Forward Call] fake quant fix #145

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Changes from 2 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
12 changes: 11 additions & 1 deletion src/compressed_tensors/quantization/lifecycle/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def maybe_calibrate_or_quantize(
return value

g_idx = getattr(module, "weight_g_idx", None)
updated_scale, updated_zero_point = None, None
horheynm marked this conversation as resolved.
Show resolved Hide resolved

if args.dynamic:
# dynamic quantization - get scale and zero point directly from observer
Expand All @@ -350,7 +351,16 @@ def maybe_calibrate_or_quantize(
update_parameter_data(module, updated_scale, f"{base_name}_scale")
update_parameter_data(module, updated_zero_point, f"{base_name}_zero_point")

return fake_quantize(value, scale, zero_point, args, g_idx=g_idx)
scale = updated_scale
zero_point = updated_zero_point

return fake_quantize(
value,
horheynm marked this conversation as resolved.
Show resolved Hide resolved
scale,
zero_point,
args,
g_idx=g_idx,
)


@torch.no_grad()
Expand Down
Loading