Skip to content
Open
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: 8 additions & 0 deletions src/llmcompressor/observers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ def get_qparams(
self._scale[i, j] = scale_bp
self._zero_point[i, j] = zp_bp

elif self.quantization_args.strategy == QuantizationStrategy.ATTN_HEAD:
# observed.shape = [batch, num_kv_heads, tokens, head_dim]
# tested only for GQA models, add support for others as needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment on this line indicates a significant limitation: this implementation has only been tested for GQA models. This could lead to silent failures or incorrect behavior with other attention types like MHA or MQA. To make this limitation more explicit and prevent potential misuse, it's better to log a warning that will be visible at runtime instead of just having a comment.

                logger.bind(log_once=True).warning(
                    "ATTN_HEAD quantization strategy has only been tested for GQA "
                    "models. Use with other model types at your own risk."
                )

self._scale, self._zero_point = self.get_qparams_along_dim(
observed,
dim=1,
)

return self._scale, self._zero_point

def get_qparams_along_dim(
Expand Down
Loading