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

Use transformers utilities when possible #2064

Merged
merged 12 commits into from
Sep 16, 2024

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Sep 13, 2024

What does this PR do?

A lot of utilities are redefined when we can just rely on transformers. I've removed most on them.
Most of https://github.com/huggingface/trl/blob/5c195eb51347ac4df7427eff4f1d636e860d13bf/tests/testing_utils.py

  • is_bitsandbytes_available
  • is_liger_available
  • is_peft_available
  • is_pil_available
  • is_wandb_available
  • is_xpu_available
  • require_peft
  • require_bitsandbytes
  • require_diffusers
  • requires_pil
  • require_wandb
  • require_torch_multi_gpu
  • require_torch_gpu
  • require_torch_multi_xpu
  • require_liger_kernel
  • require_non_cpu
  • require_multi_accelerator

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@qgallouedec qgallouedec marked this pull request as ready for review September 16, 2024 12:56
@kashif
Copy link
Collaborator

kashif commented Sep 16, 2024

@qgallouedec if we are using the helpers from transformers we might need to update the minimal transformer version to something newer? see here https://github.com/huggingface/trl/blob/main/setup.py#L80

@qgallouedec
Copy link
Member Author

Good point. In 4.39, we miss:

  • is_torch_mlu_available (added in 4.40)
  • is_liger_kernel_available (added in 4.45)

Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Thanks for the QoL improvement! I wonder if putting a lower bound on transformers leads to downstream issues in users who have a pinned, lower version of the lib? Otherwise LGTM

trl/import_utils.py Show resolved Hide resolved
@qgallouedec
Copy link
Member Author

qgallouedec commented Sep 16, 2024

Thanks for the QoL improvement! I wonder if putting a lower bound on transformers leads to downstream issues in users who have a pinned, lower version of the lib? Otherwise LGTM

pip will probably outputs something like:

trl 0.11 requires transformers>=4.40, but you have transformers 4.35 which is incompatible.

@qgallouedec qgallouedec merged commit 07f0e68 into main Sep 16, 2024
10 checks passed
@qgallouedec qgallouedec deleted the use-transformers-availability-functions branch September 16, 2024 13:56
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.

3 participants