-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scripts to convert HF lora to nemo #9102
Conversation
Signed-off-by: arendu <adithya.r@gmail.com>
Signed-off-by: arendu <adithya.r@gmail.com>
for more information, see https://pre-commit.ci
scripts/checkpoint_converters/lora_converters/convert_hf_to_canonical.py
Fixed
Show fixed
Hide fixed
def convert_lora(lora_hf_path, save_path, lora_yaml): | ||
config_file = f"{lora_hf_path}/adapter_config.json" | ||
model_file = f"{lora_hf_path}/adapter_model.bin" | ||
hf_lora_config = json.loads(open(config_file).read()) |
Check warning
Code scanning / CodeQL
File is not always closed Warning
…m/NVIDIA/NeMo into adithyare/HF_nemo_compatible_lora
Signed-off-by: arendu <adithya.r@gmail.com>
for more information, see https://pre-commit.ci
torch.save(lora_state_dict, f"{save_path}/model_weights_hf_formatted.pt") | ||
Path(save_path).mkdir(parents=True, exist_ok=True) | ||
torch.save(lora_state_dict, f"{save_path}/adapter_model.bin") | ||
adapter_config = json.load(open(args.hf_config)) |
Check warning
Code scanning / CodeQL
File is not always closed Warning
Tests passed: https://github.com/NVIDIA/NeMo/actions/runs/8977317099 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline, LGTM, thanks
@@ -145,7 +145,7 @@ inference: | |||
top_p: 0.9 # If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation. | |||
temperature: 1.0 # sampling temperature | |||
all_probs: False # whether return the log prob for all the tokens in vocab | |||
repetition_penalty: 1.2 # The parameter for repetition penalty. 1.0 means no penalty. | |||
repetition_penalty: 1.0 # The parameter for repetition penalty. 1.0 means no penalty. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will change existing inference results, are we sure we should do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
just a single comment above
* convert nemo to hf and hf to nemo Signed-off-by: arendu <adithya.r@gmail.com> * example usage Signed-off-by: arendu <adithya.r@gmail.com> * update Signed-off-by: arendu <adithya.r@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * clean up Signed-off-by: arendu <adithya.r@gmail.com> * canonicanl lora in nemo updates Signed-off-by: arendu <adithya.r@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: arendu <adithya.r@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
* convert nemo to hf and hf to nemo Signed-off-by: arendu <adithya.r@gmail.com> * example usage Signed-off-by: arendu <adithya.r@gmail.com> * update Signed-off-by: arendu <adithya.r@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * clean up Signed-off-by: arendu <adithya.r@gmail.com> * canonicanl lora in nemo updates Signed-off-by: arendu <adithya.r@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: arendu <adithya.r@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What does this PR do ?
scripts to convert hugging face lora model into nemo.
Collection: [Note which collection this PR will affect]
Changelog
Usage
GitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".
Before your PR is "Ready for review"
Pre checks:
PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.
Who can review?
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information