@@ -259,6 +259,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
259
259
# extract user-passed values from dictionary
260
260
strategy = model .strategy
261
261
group_size = model .group_size
262
+ block_structure = model .block_structure
262
263
actorder = model .actorder
263
264
dynamic = model .dynamic
264
265
observer = model .observer
@@ -277,7 +278,7 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
277
278
"strategy='group' and group_size = -1 for 'channel'"
278
279
)
279
280
280
- # validate strategy and group
281
+ # validate group strategy
281
282
if strategy == QuantizationStrategy .GROUP :
282
283
if group_size is None or group_size <= 0 :
283
284
raise ValueError (
@@ -292,6 +293,14 @@ def validate_model_after(model: "QuantizationArgs") -> "QuantizationArgs":
292
293
):
293
294
raise ValueError ("group_size requires strategy to be set to 'group'" )
294
295
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
+
295
304
# validate activation ordering and strategy
296
305
if actorder is not None and strategy != QuantizationStrategy .GROUP :
297
306
raise ValueError (
0 commit comments