llmcompressor.modifiers.transform.imatrix.base
Classes:
-
IMatrixGatherer–Lifecycle trigger for iMatrix importance collection.
IMatrixGatherer
Bases: Modifier
Lifecycle trigger for iMatrix importance collection.
Triggers a calibration pass so that IMatrixMSEObserver can collect
E[x²] via its attach() hook. Does not quantize weights — the
actual quantization is done by the subsequent
QuantizationModifier / GPTQModifier.
The observer's detach() method leaves raw _imatrix_sum and
_imatrix_count on the module for the next quantization pass
observer to pick up via attach().
Example recipe::
recipe:
- IMatrixGatherer:
ignore: ["lm_head"]
- QuantizationModifier:
config_groups:
group_0:
targets: ["Linear"]
weights:
observer: imatrix_mse
Or composed with GPTQ::
recipe:
- IMatrixGatherer:
ignore: ["lm_head"]
- GPTQModifier:
config_groups:
group_0:
targets: ["Linear"]
weights:
observer: imatrix_mse
.. note::
Auto-prepend (inserting the gatherer automatically when
imatrix_mse is detected in a recipe) is planned for a
follow-up PR.
Parameters:
-
targets–module types to instrument (default:
["Linear"]) -
ignore–layer name patterns to skip (default:
["lm_head"]) -
weight_observer–observer to attach during calibration. Must be
"imatrix_mse"(default).
Methods:
-
on_finalize–Clean up any remaining accumulators so they don't end up in the checkpoint
-
on_initialize–Attach iMatrix observers to target modules for E[x²] collection
on_finalize
Clean up any remaining accumulators so they don't end up in the checkpoint
Source code in src/llmcompressor/modifiers/transform/imatrix/base.py
on_initialize
Attach iMatrix observers to target modules for E[x²] collection