Skip to content

Commit f5db8df

Browse files
committed
Rebase and add 8-bit check
Signed-off-by: Andrea Fasoli <[email protected]>
1 parent 2784628 commit f5db8df

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fms_mo/utils/aiu_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,20 @@ def save_sd_for_aiu(
462462
logger.info(
463463
"Attention: saving state dictionary without specifying a quantization "
464464
"configuration (qcfg) performs no recomputation for narrow weight "
465-
"distributions and assumes the weight quantizer used was per-tensor."
465+
"distributions and assumes the weight quantizer used was 8-bit per-tensor."
466466
)
467+
else:
468+
nbits_w = qcfg.get("nbits_w", None)
469+
if nbits_w is None:
470+
logger.info(
471+
"Number of bits for weight quantization is not set in qcfg. "
472+
"Assuming default (nbits_w=8)."
473+
)
474+
elif nbits_w != 8:
475+
raise ValueError(
476+
"Saving checkpoint in AIU-compliant format only supports INT8 "
477+
f"quantization for now, but found {nbits_w=} in qcfg."
478+
)
467479

468480
converted_sd = convert_sd_for_aiu(
469481
model=model,

0 commit comments

Comments
 (0)