Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llmc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from llmc.models import *
from llmc.utils import (check_config, deploy_all_modality, get_modality,
mkdirs, print_important_package_version, seed_all,
update_autoawq_quant_config, update_vllm_quant_config)
update_autoawq_quant_config,
update_lightx2v_quant_config, update_vllm_quant_config)
from llmc.utils.registry_factory import ALGO_REGISTRY, MODEL_REGISTRY


Expand Down Expand Up @@ -158,6 +159,7 @@ def main(config):
elif config.save.get('save_lightx2v', False):
deploy_all_modality(blockwise_opts, 'lightx2v_quant')
blockwise_opt.save_model(save_quant_path)
update_lightx2v_quant_config(save_quant_path)

if 'opencompass' in config:
assert config.save.get('save_trans', False)
Expand Down
1 change: 1 addition & 0 deletions llmc/utils/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .export_autoawq import update_autoawq_quant_config
from .export_lightx2v import update_lightx2v_quant_config
from .export_vllm import update_vllm_quant_config
from .utils import (check_config, copy_files, deploy_all_modality,
get_modality, mkdirs, print_important_package_version,
Expand Down
11 changes: 11 additions & 0 deletions llmc/utils/export_lightx2v.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import json


def update_lightx2v_quant_config(save_quant_path):

config_file = save_quant_path + '/config.json'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using os.path.join for constructing the file path. This is more robust and cross-platform compatible.1

config_file = os.path.join(save_quant_path, 'config.json')

Style Guide References

Footnotes

  1. Using os.path.join ensures that the path is constructed correctly regardless of the operating system. (link)

with open(config_file, 'r') as file:
config_lightx2v = json.load(file)
config_lightx2v['quant_method'] = 'advanced_ptq'
with open(config_file, 'w') as file:
json.dump(config_lightx2v, file, indent=4)