Skip to content

Commit a958a33

Browse files
committed
add weight_map
Change-Id: I82fe09fb33ef5fc48139874ec9fb9aebd178a459 Signed-off-by: Yi Liu <yiliu4@habana.ai>
1 parent 6a4c67a commit a958a33

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

examples/ds/post_process.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ def update_config(model_path, qmodel_path):
5353
import json
5454
import os
5555

56-
# open config
5756
with open(os.path.join(model_path, "config.json"), "r") as f:
5857
config = json.load(f)
5958
config["quantization_config"] = quantization_config
60-
# save new config to qmodel_path
6159
logger.info(f"Updated config: {config}")
62-
logger.debug(f"Saving config to {qmodel_path}")
63-
64-
with open(os.path.join(qmodel_path, "config.json"), "w") as f:
60+
config_filepath = os.path.join(qmodel_path, "config.json")
61+
logger.debug(f"Saving config to {config_filepath}")
62+
with open(config_filepath, "w") as f:
6563
json.dump(config, f, indent=4)
6664

6765

examples/ds/quant.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,12 @@ def quant_model_weight_with_low_cpu_usage(model_path, qmodel_path):
112112
# Dump tensor mapping into json file
113113
model_state_dict_mapping_file_path = os.path.join(qmodel_path, MODEL_STATE_DICT_MAPPING_FILENAME)
114114
logger.info(f"Saving tensor mapping to {model_state_dict_mapping_file_path}")
115+
state_dict_mapping = {
116+
"metadata":{},
117+
"weight_map": qtensor_mappping,
118+
}
115119
with open(model_state_dict_mapping_file_path, "w") as f:
116-
json.dump(qtensor_mappping, f, indent=4)
120+
json.dump(state_dict_mapping, f, indent=4)
117121

118122

119123
def _import_oh():

0 commit comments

Comments
 (0)