mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-09-01 04:14:38 +08:00
feat: add update_config functionality (#531)
* feat: add `update_config` finctionality - sorts the config for better readability - updates "_name_or_path" key in config with upload_repo - sets indentation of 4 spaces - allows adding other key-value pairs via kwargs - reduces code duplication - standardizes config-update across mlx-lm * feat: standardize updating config Impactes: - fuse.py - merge.py * update formatting * remove commented out code * update func: update_config to save_config - drop kwards - rename func as save_config - incorporate review suggestions * update func: save_config - ensure only config-saving functionality - function oes not return config as a dict anymore - added review suggestions * fixed formatting * update formatting instruction in contribution guide * nits --------- Co-authored-by: Awni Hannun <awni@apple.com>
This commit is contained in:
@@ -9,7 +9,13 @@ from mlx.utils import tree_flatten, tree_unflatten
|
||||
|
||||
from .tuner.lora import LoRALinear
|
||||
from .tuner.utils import apply_lora_layers, dequantize
|
||||
from .utils import fetch_from_hub, get_model_path, save_weights, upload_to_hub
|
||||
from .utils import (
|
||||
fetch_from_hub,
|
||||
get_model_path,
|
||||
save_config,
|
||||
save_weights,
|
||||
upload_to_hub,
|
||||
)
|
||||
|
||||
|
||||
def parse_arguments() -> argparse.Namespace:
|
||||
@@ -87,8 +93,7 @@ def main() -> None:
|
||||
if args.de_quantize:
|
||||
config.pop("quantization", None)
|
||||
|
||||
with open(save_path / "config.json", "w") as fid:
|
||||
json.dump(config, fid, indent=4)
|
||||
save_config(config, config_path=save_path / "config.json")
|
||||
|
||||
if args.upload_repo is not None:
|
||||
hf_path = args.hf_path or (
|
||||
|
Reference in New Issue
Block a user