llmcompressor.observers.fusion
Classes:
-
FusionHandler–Manages fusion bookkeeping for a single Observer.
FusionHandler
Manages fusion bookkeeping for a single Observer.
Every Observer gets a FusionHandler at init time. When observers are fused (e.g. Q/K/V sharing a global_scale), FusionHandler.fuse() links their handlers together and stores weak refs to the modules whose weights may need lazy observation.
Methods:
-
fuse–Link all observers in the iterable with each other for shared global_scale.
-
get_fused_statistics–Returns statistics for every observer in the fusion group
-
maybe_delete_statistics–Cooperative statistics deletion. Each handler calls this when it
Source code in src/llmcompressor/observers/fusion.py
fuse
classmethod
Link all observers in the iterable with each other for shared global_scale. Sets module weak-references and makes handlers aware of each other.
Parameters:
-
observers_and_modules(Iterable[tuple['Observer', Module]]) –iterable of (observer, module) tuples
Source code in src/llmcompressor/observers/fusion.py
get_fused_statistics
Returns statistics for every observer in the fusion group (including this handler's own observer).
If a fused observer lacks statistics, runs observation on its module's weight via the weak ref stored during fuse().
Returns:
-
list[dict[str, Tensor]]–list of {"min_vals": Tensor, "max_vals": Tensor} dicts
Source code in src/llmcompressor/observers/fusion.py
maybe_delete_statistics
Cooperative statistics deletion. Each handler calls this when it is done with fused statistics. When ALL handlers in the group have called it, deletes statistics from every observer in the group and resets the bookkeeping.
For unfused observers, deletes statistics immediately.