generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Clean dependencies #2298
Merged
Merged
Clean dependencies #2298
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9fb772e
clean deps
qgallouedec 3691aad
new tests
qgallouedec 8d9dee3
tests
qgallouedec 9fe63f0
Add tests without optional dependencies workflow
qgallouedec ad37bdc
Update dependencies in tests.yml
qgallouedec c5c2393
cpu version of torch
qgallouedec 9e6a3df
Update dependencies and installation commands
qgallouedec 5636198
Disable fail-fast in test workflow
qgallouedec 21dcac5
Update test matrix in workflows file
qgallouedec ab6619b
try fix windows
qgallouedec 784d5a8
Remove "rich" from required packages in setup.py
qgallouedec 04aa363
Update dependency installation in tests.yml
qgallouedec ab7cb68
Add torch and deepspeed installation for windows-latest
qgallouedec c7dda4e
Fix conditional statement in workflow file
qgallouedec 16765b5
Add torch and deepspeed installation for Windows
qgallouedec 5cb82c0
Fix if statement
qgallouedec fe65acd
Update torch and deepspeed dependencies
qgallouedec 64a5a38
Update liger package requirement for non-Windows platforms
qgallouedec 8a9611e
remove scipy dep
qgallouedec 2bdcb88
Add torch GPU requirement for testing_utils
qgallouedec 9a84242
Update trl/trainer/judges.py
qgallouedec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: tests | ||
name: Tests | ||
|
||
on: | ||
push: | ||
|
@@ -15,76 +15,101 @@ on: | |
|
||
env: | ||
TQDM_DISABLE: 1 | ||
CI_SLACK_CHANNEL: ${{ secrets.CI_PUSH_MAIN_CHANNEL }} | ||
|
||
jobs: | ||
check_code_quality: | ||
runs-on: ubuntu-latest | ||
tests: | ||
name: Tests | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
os: ['ubuntu-latest', 'windows-latest'] | ||
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- uses: pre-commit/[email protected] | ||
cache: "pip" | ||
cache-dependency-path: | | ||
setup.py | ||
requirements.txt | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install ".[dev]" | ||
- name: Test with pytest | ||
run: | | ||
make test | ||
- name: Post to Slack | ||
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main | ||
uses: huggingface/hf-workflows/.github/actions/post-slack@main | ||
with: | ||
extra_args: --all-files | ||
slack_channel: ${{ env.CI_SLACK_CHANNEL }} | ||
title: 🤗 Results of the TRL CI with dev dependencies | ||
status: ${{ job.status }} | ||
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | ||
|
||
tests: | ||
needs: check_code_quality | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11'] | ||
os: ['ubuntu-latest', 'windows-latest'] | ||
runs-on: ${{ matrix.os }} | ||
tests_dev: | ||
name: Tests with dev dependencies | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
cache-dependency-path: | | ||
setup.py | ||
requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
# install PEFT & transformers from source | ||
pip install -U git+https://github.com/huggingface/peft.git | ||
pip install -U git+https://github.com/huggingface/transformers.git | ||
# cpu version of pytorch | ||
pip install ".[test, diffusers]" | ||
- name: Test with pytest | ||
run: | | ||
make test | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: "pip" | ||
cache-dependency-path: | | ||
setup.py | ||
requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -U git+https://github.com/huggingface/accelerate.git | ||
python -m pip install -U git+https://github.com/huggingface/datasets.git | ||
python -m pip install -U git+https://github.com/huggingface/transformers.git | ||
python -m pip install ".[dev]" | ||
- name: Test with pytest | ||
run: | | ||
make test | ||
- name: Post to Slack | ||
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main | ||
uses: huggingface/hf-workflows/.github/actions/post-slack@main | ||
with: | ||
slack_channel: ${{ env.CI_SLACK_CHANNEL }} | ||
title: 🤗 Results of the TRL CI with dev dependencies | ||
status: ${{ job.status }} | ||
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | ||
|
||
tests_no_optional_dep: | ||
needs: check_code_quality | ||
tests_wo_optional_deps: | ||
name: Tests without optional dependencies | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
cache: "pip" | ||
cache-dependency-path: | | ||
setup.py | ||
requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
# install transformers from source | ||
pip install -U git+https://github.com/huggingface/transformers.git | ||
# cpu version of pytorch | ||
pip install .[test] | ||
- name: Test with pytest | ||
run: | | ||
make test | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: "pip" | ||
cache-dependency-path: | | ||
setup.py | ||
requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install ".[test]" | ||
- name: Test with pytest | ||
run: | | ||
make test | ||
- name: Post to Slack | ||
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main | ||
uses: huggingface/hf-workflows/.github/actions/post-slack@main | ||
with: | ||
slack_channel: ${{ env.CI_SLACK_CHANNEL }} | ||
title: 🤗 Results of the TRL CI with dev dependencies | ||
status: ${{ job.status }} | ||
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
datasets>=1.17.0 | ||
torch>=1.4.0 | ||
tqdm | ||
transformers>=4.46.0 | ||
accelerate | ||
peft>=0.3.0 | ||
tyro>=0.5.7 | ||
datasets | ||
rich | ||
transformers>=4.46.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,10 @@ | |
|
||
import torch | ||
from transformers import AutoModelForCausalLM | ||
from transformers.testing_utils import require_bitsandbytes, require_peft | ||
from transformers.testing_utils import ( | ||
require_peft, | ||
require_torch_gpu_if_bnb_not_multi_backend_enabled, | ||
) | ||
from transformers.utils import is_peft_available | ||
|
||
from trl import AutoModelForCausalLMWithValueHead | ||
|
@@ -95,7 +98,7 @@ def test_create_peft_model_from_config(self): | |
nb_trainable_params = sum(p.numel() for p in trl_model.parameters() if p.requires_grad) | ||
assert nb_trainable_params == 10273 | ||
|
||
@require_bitsandbytes | ||
@require_torch_gpu_if_bnb_not_multi_backend_enabled | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it requires cuda |
||
def test_create_bnb_peft_model_from_config(self): | ||
r""" | ||
Simply creates a peft model and checks that it can be loaded. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
import numpy as np | ||
from accelerate import Accelerator | ||
from huggingface_hub import InferenceClient | ||
from scipy.special import softmax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this dep |
||
from transformers.utils import is_openai_available | ||
|
||
from ..import_utils import is_llmblender_available | ||
|
@@ -239,7 +238,13 @@ def judge( | |
ranks[flip_mask] = ranks[flip_mask][:, ::-1] | ||
|
||
# Return the ranks or score probability | ||
return softmax(ranks, axis=-1)[:, 0].tolist() if return_scores else ranks[:, 0].tolist() | ||
if return_scores: | ||
logit_max = np.amax(ranks, axis=-1, keepdims=True) | ||
exp_logit_shifted = np.exp(ranks - logit_max) | ||
probs = exp_logit_shifted / np.sum(exp_logit_shifted, axis=-1, keepdims=True) | ||
return probs[:, 0].tolist() | ||
else: | ||
return ranks[:, 0].tolist() | ||
|
||
|
||
class HfPairwiseJudge(BasePairwiseJudge): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If we find the dependencies are a hassle to maintain, we might want to switch to the
transformers
approach, which uses a look-up table to give fine-grained control: https://github.com/huggingface/transformers/blob/main/setup.py