Skip to content

Commit

Permalink
set default for merge (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamelsmu committed Jan 5, 2024
1 parent 31d2350 commit 63fb3eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1036,10 +1036,10 @@ Please use `--sample_packing False` if you have it on and receive the error simi
### Merge LORA to base

Add below flag to train command above
The following command will merge your LORA adapater with your base model. You can optionally pass the argument `--lora_model_dir` to specify the directory where your LORA adapter was saved, otherwhise, this will be inferred from `output_dir` in your axolotl config file. The merged model is saved in the sub-directory `{lora_model_dir}/merged`.

```bash
python3 -m axolotl.cli.merge_lora examples/your_config.yml --lora_model_dir="./completed-model"
python3 -m axolotl.cli.merge_lora your_config.yml --lora_model_dir="./completed-model"
```

If you run out of CUDA memory, you can try to merge in system RAM with
Expand Down
9 changes: 8 additions & 1 deletion src/axolotl/cli/merge_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ def do_cli(config: Path = Path("examples/"), **kwargs):
load_in_8bit=False,
load_in_4bit=False,
flash_attention=False,
**kwargs
**kwargs,
)

if not parsed_cfg.lora_model_dir and parsed_cfg.output_dir:
parsed_cfg.lora_model_dir = parsed_cfg.output_dir
if not Path(parsed_cfg.lora_model_dir).exists():
raise ValueError(
f"Target directory for merge: `{parsed_cfg.lora_model_dir}` does not exist."
)

do_merge_lora(cfg=parsed_cfg, cli_args=parsed_cli_args)


Expand Down

0 comments on commit 63fb3eb

Please sign in to comment.