Skip to content

Commit a6bd15a

Browse files
committed
test: Added qcfg recipe test to for qconfig_save + qconfig_init
Signed-off-by: Brandon Groth <[email protected]>
1 parent 00bad82 commit a6bd15a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/models/test_saveconfig.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pytest
2121

2222
# Local
23+
from fms_mo import qconfig_init
2324
from fms_mo.utils.qconfig_utils import qconfig_load, qconfig_save
2425
from tests.models.test_model_utils import (
2526
delete_file,
@@ -298,3 +299,31 @@ def test_load_config_required_pair(
298299

299300
loaded_config = qconfig_load("qcfg.json")
300301
assert loaded_config.get(key) == default_val
302+
303+
304+
def test_save_init_recipe(
305+
config_int8: dict,
306+
):
307+
"""
308+
Change a config, save it,
309+
310+
Args:
311+
config_fp32 (dict): Config for fp32 quantization
312+
"""
313+
# Change some elements of config to ensure its being saved/loaded properly
314+
config_int8["qa_mode"] = "minmax"
315+
config_int8["qa_mode"] = "pertokenmax"
316+
config_int8["qmodel_calibration"] = 17
317+
config_int8["qskip_layer_name"] = ["lm_head"]
318+
319+
qconfig_save(config_int8)
320+
recipe_config = qconfig_init(recipe="qcfg.json")
321+
322+
# Remove date field from recipe_config - only added at save
323+
del recipe_config["date"]
324+
325+
assert len(recipe_config) == len(config_int8)
326+
327+
for key, val in config_int8.items():
328+
assert key in recipe_config
329+
assert recipe_config.get(key) == val

0 commit comments

Comments
 (0)