Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/compressed_tensors/quantization/lifecycle/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ def _initialize_scale_zero_point(
# 2. Infer expected scale/zero point shape
if quantization_args.strategy == QuantizationStrategy.TOKEN:
expected_shape = (1, 1)
elif quantization_args.strategy == QuantizationStrategy.ATTN_HEAD:
# supports only GQA models, support others when/if needed
if base_name == "q":
expected_shape = module.config.num_attention_heads
elif base_name in ("k", "v"):
expected_shape = module.config.num_key_value_heads
else:
raise ValueError(
f"Unsupported target {type(module)} for per-attention-head quantization"
)
else:
expected_shape = 1

Expand Down
1 change: 1 addition & 0 deletions src/compressed_tensors/quantization/quant_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class QuantizationStrategy(str, Enum):
BLOCK = "block"
TOKEN = "token"
TENSOR_GROUP = "tensor_group"
ATTN_HEAD = "attn_head"


class DynamicType(str, Enum):
Expand Down