Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 1b83d9b

Browse files
anmarquesbfineran
andauthored
Add weight qconfig properties to forward_fn in case it contains weights (#940)
Co-authored-by: Benjamin Fineran <bfineran@users.noreply.github.com>
1 parent 5774006 commit 1b83d9b

File tree

1 file changed

+7
-0
lines changed
  • src/sparseml/pytorch/sparsification/quantization

1 file changed

+7
-0
lines changed

src/sparseml/pytorch/sparsification/quantization/helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ def __init__(
256256
num_input_quant_stubs = num_inputs + len(self.kwarg_input_names)
257257

258258
self.forward_fn = forward_fn
259+
# Add weight qconfig to forward_fn (in case it has weights)
260+
qconfig_ = get_qat_qconfig(qproperties)
261+
qconfig = torch_quantization.QConfig(
262+
activation=torch.nn.Identity,
263+
weight=qconfig_.weight,
264+
)
265+
self.forward_fn.qconfig = qconfig
259266

260267
self.input_qconfigs = self._load_qconfigs(
261268
name="input_qconfigs",

0 commit comments

Comments
 (0)