Skip to content

Commit 15450a1

Browse files
committed
add validation
Signed-off-by: Kyle Sayers <[email protected]>
1 parent b5dc1e9 commit 15450a1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compressed_tensors/quantization/quant_args.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
259259
# extract user-passed values from dictionary
260260
strategy = model.strategy
261261
group_size = model.group_size
262+
block_structure = model.block_structure
262263
actorder = model.actorder
263264
dynamic = model.dynamic
264265
observer = model.observer
@@ -277,7 +278,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
277278
"strategy='group' and group_size = -1 for 'channel'"
278279
)
279280

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

296+
# validate block strategy
297+
has_block_strategy = strategy == QuantizationStrategy.BLOCK
298+
has_block_structure = block_structure is not None
299+
if has_block_strategy and not has_block_structure:
300+
raise ValueError(f"Block strategy requires block structure\n{model}")
301+
if has_block_structure and not has_block_strategy:
302+
raise ValueError(f"Block structure requires block strategy\n{model}")
303+
295304
# validate activation ordering and strategy
296305
if actorder is not None and strategy != QuantizationStrategy.GROUP:
297306
raise ValueError(

0 commit comments

Comments
 (0)