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 forward function pass call #845

Merged
merged 3 commits into from
Oct 19, 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
8 changes: 3 additions & 5 deletions src/llmcompressor/modifiers/obcq/utils/sgpt_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import time

from compressed_tensors.quantization.lifecycle.forward import (
maybe_calibrate_or_quantize,
)
from compressed_tensors.quantization.lifecycle.forward import forward_quantize

from llmcompressor.modifiers.utils.compression_wrapper import ModuleCompressionWrapper
from llmcompressor.utils import getattr_chain
Expand Down Expand Up @@ -95,7 +93,7 @@ def compress(
args_loc = "quantization_scheme.weights"
weight_quant_args = getattr_chain(self.layer, args_loc, None)
if weight_quant_args is not None:
W = maybe_calibrate_or_quantize(self.layer, W, "weight", weight_quant_args)
W = forward_quantize(self.layer, W, "weight", weight_quant_args)

if isinstance(self.layer, nn.Conv2d):
W = W.flatten(1)
Expand Down Expand Up @@ -213,7 +211,7 @@ def compress(
W = W.t()
W = W.reshape(final_shape).to(final_dtype)
if weight_quant_args is not None:
W = maybe_calibrate_or_quantize(self.layer, W, "weight", weight_quant_args)
W = forward_quantize(self.layer, W, "weight", weight_quant_args)

# This is a bit hacky, but FSDP updates only work if we change the weight in
# place, clone() or direct assignment won't work
Expand Down
Loading