Skip to content
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

fix PeftConfig loading from a remote repo. #649

Merged
merged 6 commits into from
Aug 24, 2023

Conversation

w32zhong
Copy link
Contributor

I am using peft 0.4.0 (currently the most updated one), it requires PeftConfig.from_pretrained() to be passed a directory, instead of the config file path.

At least in huggingface-hub 0.10.1, the error for "not found" is:
huggingface_hub.utils._errors.EntryNotFoundError: 404 Client Error
@lvwerra lvwerra requested a review from younesbelkada August 16, 2023 08:15
@lvwerra
Copy link
Member

lvwerra commented Aug 16, 2023

Thanks for the PR! I let @younesbelkada review it as he built that part of the repo - he's back from vacation next week.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

This looks good I think, left one comment, also can you run make precommit ? Thanks!

@@ -263,7 +264,7 @@ class and the arguments that are specific to trl models. The kwargs
"pytorch_model.bin.index.json",
token=token,
)
except ValueError: # not continue training, do not have v_head weight
except: # not continue training, do not have v_head weight
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate why this change is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @younesbelkada, thanks for getting back! This change has two reasons:

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, that makes sense, would you be happy to import EntryNotFoundError from huggingface_hub similarly as here: https://github.com/huggingface/transformers/blob/main/src/transformers/utils/hub.py#L43 and replace the bare excepts with except EntryNotFoundError:? 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @younesbelkada, I am thinking this would be a little tricky, as you might notice, there are many error codes, and the logics / handler is the same for any of them? So bare excepts will be reasonable in this case? Or we can just use the general Exception form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I see only two error codes are sufficient for the purpose. I have made the proposed changes and applied it to other places in that file as well. Please review it in my most recent commit.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 18, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Hi @w32zhong
Thanks a lot for iterating, sadly some CIs are failing, you can try to run:

pytest tests/test_peft_models.py::PeftModelTester::test_continue_training_peft_model

Can you please try to have a look 🙏 Let me know if you need any help !

@w32zhong
Copy link
Contributor Author

w32zhong commented Aug 23, 2023

@younesbelkada Sorry for getting back to you late.

I've checked the exception that causes the failure of testcase. It is huggingface_hub.utils._validators.HFValidationError. As I assumed, it is not easy to enumerate all potential error types in this scenario. So personally I would suggest to use bare except in this case.

That being said, I have added HFValidationError into the catch cases. See if this will pass all testcases.

@w32zhong w32zhong closed this Aug 23, 2023
@w32zhong w32zhong reopened this Aug 23, 2023
@w32zhong
Copy link
Contributor Author

Looks like this test failed:

pytest tests/test_reward_trainer.py::RewardTrainerTester::test_reward_trainer_assert_value_error

But a local run gives me error on the missing wandb api key. Any idea how to proceed?

@younesbelkada
Copy link
Contributor

Hi @w32zhong
Thanks a lot for iterating, regarding the failing test it is unrelated to your PR, it should be solved with #676
Once #676 gets merged, you can merge your branch with upstream main and the CI will be green once again

@younesbelkada
Copy link
Contributor

Hi @w32zhong
You can now merge with main branch and the CI will be green

@w32zhong
Copy link
Contributor Author

@younesbelkada done.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Looking great thank you!

@younesbelkada younesbelkada merged commit b095245 into huggingface:main Aug 24, 2023
kushal-tri pushed a commit to kushalarora/trl that referenced this pull request Sep 19, 2023
* fix PeftConfig loading from a remote repo.

* failed to catch hf_hub_download() EntryNotFoundError.

At least in huggingface-hub 0.10.1, the error for "not found" is:
huggingface_hub.utils._errors.EntryNotFoundError: 404 Client Error

* pass precommit checks.

* replace some bare excepts with specific codes

* catch LocalEntryNotFoundError additionally.
lapp0 pushed a commit to lapp0/trl that referenced this pull request May 10, 2024
* fix PeftConfig loading from a remote repo.

* failed to catch hf_hub_download() EntryNotFoundError.

At least in huggingface-hub 0.10.1, the error for "not found" is:
huggingface_hub.utils._errors.EntryNotFoundError: 404 Client Error

* pass precommit checks.

* replace some bare excepts with specific codes

* catch LocalEntryNotFoundError additionally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants