File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
examples/models/llama/config Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,9 @@ def __post_init__(self):
331
331
self ._validate_qmode ()
332
332
333
333
def _validate_qmode (self ) -> None :
334
+ if not self .qmode :
335
+ return
336
+
334
337
if self .qmode in self .QMODE_OPTIONS :
335
338
return
336
339
@@ -466,13 +469,20 @@ class LlmConfig:
466
469
backend : BackendConfig = field (default_factory = BackendConfig )
467
470
468
471
def __post_init__ (self ):
469
- # If we are using Ao's low bit quantization kernels for ARM,
470
- # we do not want to also be delegating to a CPU backend (XNNPack).
472
+ self ._validate_low_bit_no_xnnpack ()
473
+
474
+ def _validate_low_bit (self ):
475
+ if not self .quantization .qmode :
476
+ return
477
+
471
478
using_lowbit_ops = False
472
479
for pattern in self .quantization .AO_QUANT_PATTERNS :
473
480
matches = re .findall (pattern , self .quantization .qmode )
474
481
if len (matches ) == 1 :
475
482
using_lowbit_ops = True
483
+
484
+ # If we are using Ao's low bit quantization kernels for ARM,
485
+ # we do not want to also be delegating to a CPU backend (XNNPack).
476
486
if using_lowbit_ops and self .backend .xnnpack .enabled :
477
487
raise ValueError (
478
488
"Cannot use low-bit Ao ops (from qmode=torchao:...) while also delegating to XNNPack."
You can’t perform that action at this time.
0 commit comments