Skip to content
Merged
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion src/compressed_tensors/quantization/quant_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
# extract user-passed values from dictionary
strategy = model.strategy
group_size = model.group_size
block_structure = model.block_structure
actorder = model.actorder
dynamic = model.dynamic
observer = model.observer
Expand All @@ -277,7 +278,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
"strategy='group' and group_size = -1 for 'channel'"
)

# validate strategy and group
# validate group strategy
if strategy == QuantizationStrategy.GROUP:
if group_size is None or group_size <= 0:
raise ValueError(
Expand All @@ -292,6 +293,14 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
):
raise ValueError("group_size requires strategy to be set to 'group'")

# validate block strategy
has_block_strategy = strategy == QuantizationStrategy.BLOCK
has_block_structure = block_structure is not None
if has_block_strategy and not has_block_structure:
raise ValueError(f"Block strategy requires block structure\n{model}")
if has_block_structure and not has_block_strategy:
raise ValueError(f"Block structure requires block strategy\n{model}")

# validate activation ordering and strategy
if actorder is not None and strategy != QuantizationStrategy.GROUP:
raise ValueError(
Expand Down
Loading