Skip to content

Commit 5566f1b

Browse files
authored
🏃 Migrate CI to self-hosted runners (huggingface#3174)
1 parent 30b83ae commit 5566f1b

16 files changed

+177
-147
lines changed

.github/workflows/tests.yml

Lines changed: 129 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
if: github.event.pull_request.draft == false
2525
steps:
2626
- uses: actions/checkout@v4
27-
with:
28-
fetch-depth: 0
29-
submodules: recursive
3027
- name: Set up Python 3.12
3128
uses: actions/setup-python@v5
3229
with:
@@ -40,129 +37,215 @@ jobs:
4037
strategy:
4138
matrix:
4239
python-version: ['3.9', '3.10', '3.11', '3.12']
43-
os: ['ubuntu-latest', 'windows-latest']
4440
fail-fast: false
45-
runs-on: ${{ matrix.os }}
41+
runs-on:
42+
group: aws-g4dn-2xlarge
43+
container:
44+
image: pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel
45+
options: --gpus all
46+
defaults:
47+
run:
48+
shell: bash
4649
if: github.event.pull_request.draft == false
4750
steps:
48-
- uses: actions/checkout@v4
51+
- name: Git checkout
52+
uses: actions/checkout@v4
53+
4954
- name: Set up Python ${{ matrix.python-version }}
5055
uses: actions/setup-python@v5
5156
with:
5257
python-version: ${{ matrix.python-version }}
53-
cache: "pip"
54-
cache-dependency-path: |
55-
setup.py
56-
requirements.txt
58+
59+
- name: Install Make and Git
60+
run: |
61+
apt-get update && apt-get install -y make git curl
62+
63+
- name: Install uv
64+
run: |
65+
curl -LsSf https://astral.sh/uv/install.sh | sh
66+
67+
- name: Create Python virtual environment
68+
run: |
69+
uv venv
70+
uv pip install --upgrade setuptools wheel
5771
5872
- name: Install dependencies
5973
run: |
60-
python -m pip install --upgrade pip
61-
python -m pip install ".[dev]"
74+
source .venv/bin/activate
75+
uv pip install ".[dev]"
76+
6277
- name: Test with pytest
6378
run: |
79+
source .venv/bin/activate
6480
make test
81+
6582
- name: Post to Slack
6683
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main
6784
uses: huggingface/hf-workflows/.github/actions/post-slack@main
6885
with:
6986
slack_channel: ${{ env.CI_SLACK_CHANNEL }}
70-
title: Results with Python ${{ matrix.python-version }} on ${{ matrix.os }} with lastest dependencies
87+
title: Results with Python ${{ matrix.python-version }} and latest dependencies
7188
status: ${{ job.status }}
7289
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
7390

7491
tests_dev:
7592
name: Tests with dev dependencies
76-
runs-on: 'ubuntu-latest'
93+
runs-on:
94+
group: aws-g4dn-2xlarge
95+
container:
96+
image: pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel
97+
options: --gpus all
98+
defaults:
99+
run:
100+
shell: bash
77101
if: github.event.pull_request.draft == false
78102
steps:
79-
- uses: actions/checkout@v4
103+
- name: Git checkout
104+
uses: actions/checkout@v4
105+
80106
- name: Set up Python 3.12
81107
uses: actions/setup-python@v5
82108
with:
83109
python-version: '3.12'
84-
cache: "pip"
85-
cache-dependency-path: |
86-
setup.py
87-
requirements.txt
110+
111+
- name: Install Make and Git
112+
run: |
113+
apt-get update && apt-get install -y make git curl
114+
115+
- name: Install uv
116+
run: |
117+
curl -LsSf https://astral.sh/uv/install.sh | sh
118+
119+
- name: Create Python virtual environment
120+
run: |
121+
uv venv
122+
uv pip install --upgrade setuptools wheel
123+
88124
- name: Install dependencies
89125
run: |
90-
python -m pip install --upgrade pip
91-
python -m pip install -U git+https://github.com/huggingface/accelerate.git
92-
python -m pip install -U git+https://github.com/huggingface/datasets.git
93-
python -m pip install -U git+https://github.com/huggingface/transformers.git
94-
python -m pip install ".[dev]"
126+
source .venv/bin/activate
127+
uv pip install -U git+https://github.com/huggingface/accelerate.git
128+
uv pip install -U git+https://github.com/huggingface/datasets.git
129+
uv pip install -U git+https://github.com/huggingface/transformers.git
130+
uv pip install ".[dev]"
131+
95132
- name: Test with pytest
96133
run: |
134+
source .venv/bin/activate
97135
make test
136+
98137
- name: Post to Slack
99138
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main
100139
uses: huggingface/hf-workflows/.github/actions/post-slack@main
101140
with:
102141
slack_channel: ${{ env.CI_SLACK_CHANNEL }}
103-
title: Results with Python 3.12 on ubuntu-latest with dev dependencies
142+
title: Results with Python 3.12 and dev dependencies
104143
status: ${{ job.status }}
105144
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
106145

107146
tests_wo_optional_deps:
108147
name: Tests without optional dependencies
109-
runs-on: 'ubuntu-latest'
148+
runs-on:
149+
group: aws-g4dn-2xlarge
150+
container:
151+
image: pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel
152+
options: --gpus all
153+
defaults:
154+
run:
155+
shell: bash
110156
if: github.event.pull_request.draft == false
111157
steps:
112-
- uses: actions/checkout@v4
158+
- name: Git checkout
159+
uses: actions/checkout@v4
160+
113161
- name: Set up Python 3.12
114162
uses: actions/setup-python@v5
115163
with:
116164
python-version: '3.12'
117-
cache: "pip"
118-
cache-dependency-path: |
119-
setup.py
120-
requirements.txt
165+
166+
- name: Install Make and Git
167+
run: |
168+
apt-get update && apt-get install -y make git curl
169+
170+
- name: Install uv
171+
run: |
172+
curl -LsSf https://astral.sh/uv/install.sh | sh
173+
174+
- name: Create Python virtual environment
175+
run: |
176+
uv venv
177+
uv pip install --upgrade setuptools wheel
178+
121179
- name: Install dependencies
122180
run: |
123-
python -m pip install --upgrade pip
124-
python -m pip install ".[test]"
181+
source .venv/bin/activate
182+
uv pip install ".[test]"
183+
125184
- name: Test with pytest
126185
run: |
186+
source .venv/bin/activate
127187
make test
188+
128189
- name: Post to Slack
129190
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main
130191
uses: huggingface/hf-workflows/.github/actions/post-slack@main
131192
with:
132193
slack_channel: ${{ env.CI_SLACK_CHANNEL }}
133-
title: Results with Python 3.12 on ubuntu-latest without optional dependencies
194+
title: Results with Python 3.12 without optional dependencies
134195
status: ${{ job.status }}
135196
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
136197

137198
tests_min_versions:
138199
name: Tests with minimum versions
139-
runs-on: 'ubuntu-latest'
200+
runs-on:
201+
group: aws-g4dn-2xlarge
202+
container:
203+
image: pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel
204+
options: --gpus all
205+
defaults:
206+
run:
207+
shell: bash
140208
if: github.event.pull_request.draft == false
141209
steps:
142-
- uses: actions/checkout@v4
210+
- name: Git checkout
211+
uses: actions/checkout@v4
212+
143213
- name: Set up Python 3.12
144214
uses: actions/setup-python@v5
145215
with:
146216
python-version: '3.12'
147-
cache: "pip"
148-
cache-dependency-path: |
149-
setup.py
150-
requirements.txt
217+
218+
- name: Install Make and Git
219+
run: |
220+
apt-get update && apt-get install -y make git curl
221+
222+
- name: Install uv
223+
run: |
224+
curl -LsSf https://astral.sh/uv/install.sh | sh
225+
226+
- name: Create Python virtual environment
227+
run: |
228+
uv venv
229+
uv pip install --upgrade setuptools wheel
230+
151231
- name: Install dependencies
152232
run: |
153-
python -m pip install --upgrade pip
154-
python -m pip install accelerate==0.34.0
155-
python -m pip install datasets==3.0.0
156-
python -m pip install transformers==4.46.0
157-
python -m pip install ".[dev]"
233+
source .venv/bin/activate
234+
uv pip install accelerate==0.34.0
235+
uv pip install datasets==3.0.0
236+
uv pip install transformers==4.46.0
237+
uv pip install ".[dev]"
238+
158239
- name: Test with pytest
159240
run: |
241+
source .venv/bin/activate
160242
make test
243+
161244
- name: Post to Slack
162245
if: github.ref == 'refs/heads/main' && always() # Check if the branch is main
163246
uses: huggingface/hf-workflows/.github/actions/post-slack@main
164247
with:
165248
slack_channel: ${{ env.CI_SLACK_CHANNEL }}
166-
title: Results with Python 3.12 on ubuntu-latest with minimum versions
249+
title: Results with Python 3.12 and minimum dependencies versions
167250
status: ${{ job.status }}
168251
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}

.github/workflows/tests_latest.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,54 @@ env:
1313
jobs:
1414
tests:
1515
name: Tests latest TRL release with dev dependencies
16-
runs-on: 'ubuntu-latest'
16+
runs-on:
17+
group: aws-g4dn-2xlarge
18+
container:
19+
image: pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel
20+
options: --gpus all
21+
defaults:
22+
run:
23+
shell: bash
1724
steps:
1825
- name: Git checkout
1926
uses: actions/checkout@v4
2027
with: { ref: v0.16-release }
28+
2129
- name: Set up Python 3.12
2230
uses: actions/setup-python@v5
2331
with:
2432
python-version: '3.12'
25-
cache: "pip"
26-
cache-dependency-path: |
27-
setup.py
28-
requirements.txt
33+
34+
- name: Install Make and Git
35+
run: |
36+
apt-get update && apt-get install -y make git curl
37+
38+
- name: Install uv
39+
run: |
40+
curl -LsSf https://astral.sh/uv/install.sh | sh
41+
42+
- name: Create Python virtual environment
43+
run: |
44+
uv venv
45+
uv pip install --upgrade setuptools wheel
46+
2947
- name: Install dependencies
3048
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install -U git+https://github.com/huggingface/accelerate.git
33-
python -m pip install -U git+https://github.com/huggingface/datasets.git
34-
python -m pip install -U git+https://github.com/huggingface/transformers.git
35-
python -m pip install ".[dev]"
49+
source .venv/bin/activate
50+
uv pip install -U git+https://github.com/huggingface/accelerate.git
51+
uv pip install -U git+https://github.com/huggingface/datasets.git
52+
uv pip install -U git+https://github.com/huggingface/transformers.git
53+
uv pip install ".[dev]"
54+
3655
- name: Test with pytest
3756
run: |
57+
source .venv/bin/activate
3858
make test
59+
3960
- name: Post to Slack
4061
uses: huggingface/hf-workflows/.github/actions/post-slack@main
4162
with:
4263
slack_channel: ${{ env.CI_SLACK_CHANNEL }}
43-
title: Results of latest TRL with Python 3.12 on ubuntu-latest with dev dependencies
64+
title: Results of latest TRL with Python 3.12 and dev dependencies
4465
status: ${{ job.status }}
4566
slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ Follow these steps to start contributing:
171171
$ pytest tests/<TEST_TO_RUN>.py
172172
```
173173

174-
> For the following commands leveraging the `make` utility, we recommend using the WSL system when running on
175-
> Windows. More information [here](https://docs.microsoft.com/en-us/windows/wsl/about).
174+
> For the following commands leveraging the `make` utility.
176175
177176
You can also run the full suite with the following command.
178177

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ ACCELERATE_CONFIG_PATH = `pwd`/examples/accelerate_configs
66
COMMAND_FILES_PATH = `pwd`/commands
77

88
test:
9-
python -m pytest -n auto --dist=loadfile -s -v --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504||not less than or equal to 0.01)' ./tests/
9+
pytest -n auto --dist=loadfile -s -v --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504||not less than or equal to 0.01)' ./tests/
1010

1111
precommit:
1212
python scripts/add_copyrights.py
1313
pre-commit run --all-files
1414

15-
tests_gpu:
16-
python -m pytest tests/test_* $(if $(IS_GITHUB_CI),--report-log "common_tests.log",)
17-
1815
slow_tests:
19-
python -m pytest tests/slow/test_* $(if $(IS_GITHUB_CI),--report-log "slow_tests.log",)
16+
pytest tests/slow/test_* $(if $(IS_GITHUB_CI),--report-log "slow_tests.log",)
2017

2118
test_examples:
2219
touch temp_results_sft_tests.txt

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,17 @@
7878
"transformers>=4.46.0",
7979
]
8080
EXTRAS = {
81-
# Windows support is partially supported with DeepSpeed https://github.com/microsoft/DeepSpeed/tree/master#windows
82-
"deepspeed": ["deepspeed>=0.14.4; sys_platform != 'win32'"],
81+
"deepspeed": ["deepspeed>=0.14.4"],
8382
"diffusers": ["diffusers>=0.18.0"],
8483
"judges": ["openai>=1.23.2", "llm-blender>=0.0.2"],
85-
# liger-kernel depends on triton, which is only available on Linux https://github.com/triton-lang/triton#compatibility
86-
"liger": ["liger-kernel>=0.5.5; sys_platform == 'Linux'"],
84+
"liger": ["liger-kernel>=0.5.5"],
8785
"mergekit": ["mergekit>=0.0.5.1"],
8886
"peft": ["peft>=0.8.0"],
8987
"quantization": ["bitsandbytes"],
9088
"scikit": ["scikit-learn"],
9189
"bco": ["scikit-learn", "joblib"],
9290
"test": ["parameterized", "pytest-cov", "pytest-rerunfailures", "pytest-xdist", "pytest"],
93-
# vllm is not available on Windows
94-
"vllm": ["vllm>=0.7.0; sys_platform != 'win32'", "fastapi", "pydantic", "requests", "uvicorn"],
91+
"vllm": ["vllm>=0.7.0", "fastapi", "pydantic", "requests", "uvicorn"],
9592
"vlm": ["Pillow"],
9693
}
9794
EXTRAS["dev"] = []

tests/slow/test_dpo_slow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737

3838
@require_torch_accelerator
39+
@require_peft
3940
class DPOTrainerSlowTester(unittest.TestCase):
4041
def setUp(self):
4142
self.dataset = load_dataset("trl-internal-testing/zen", "standard_preference")

0 commit comments

Comments
 (0)