Set up Python explicitly in the slow tests workflow (#6884) #20347
This file contains hidden or 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
| name: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - ci-* | |
| pull_request: | |
| paths: | |
| # Run only when relevant files are modified | |
| - ".github/**.yml" | |
| - "examples/**.py" | |
| - "scripts/**.py" | |
| - "tests/**.py" | |
| - "trl/**.py" | |
| - "pyproject.toml" | |
| # Exclude if only experimental code/tests | |
| - "!trl/experimental/**" | |
| - "!tests/experimental/**" | |
| env: | |
| TQDM_DISABLE: 1 | |
| CI_SLACK_CHANNEL: ${{ secrets.CI_PUSH_MAIN_CHANNEL }} | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| PYTORCH_CUDA_ALLOC_CONF: "expandable_segments:True" | |
| PYTORCH_ALLOC_CONF: "expandable_segments:True" | |
| jobs: | |
| check_code_quality: | |
| name: Check code quality | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | |
| with: | |
| extra_args: --all-files | |
| tests: | |
| name: Tests with latest dependencies | |
| runs-on: | |
| group: aws-g6e-4xlarge | |
| container: | |
| image: pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel | |
| options: --gpus all | |
| defaults: | |
| run: | |
| shell: bash | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Make and Git | |
| run: | | |
| apt-get update && apt-get install -y make git curl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| - name: Create Python virtual environment | |
| run: | | |
| uv venv | |
| uv pip install --upgrade setuptools wheel | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install ".[dev]" | |
| - name: Test with pytest | |
| run: | | |
| source .venv/bin/activate | |
| 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 with latest dependencies | |
| status: ${{ job.status }} | |
| slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | |
| tests_dev: | |
| name: Tests with dev dependencies | |
| runs-on: | |
| group: aws-g6e-4xlarge | |
| container: | |
| image: pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel | |
| options: --gpus all | |
| defaults: | |
| run: | |
| shell: bash | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Make and Git | |
| run: | | |
| apt-get update && apt-get install -y make git curl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| - name: Create Python virtual environment | |
| run: | | |
| uv venv | |
| uv pip install --upgrade setuptools wheel | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install -U \ | |
| ".[dev]" \ | |
| "accelerate @ git+https://github.com/huggingface/accelerate.git" \ | |
| "datasets @ git+https://github.com/huggingface/datasets.git" \ | |
| "transformers @ git+https://github.com/huggingface/transformers.git" \ | |
| "peft @ git+https://github.com/huggingface/peft.git" | |
| - name: Test with pytest | |
| run: | | |
| source .venv/bin/activate | |
| 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 with dev dependencies | |
| status: ${{ job.status }} | |
| slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | |
| tests_wo_optional_deps: | |
| name: Tests without optional dependencies | |
| runs-on: | |
| group: aws-g6e-4xlarge | |
| container: | |
| image: pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel | |
| options: --gpus all | |
| defaults: | |
| run: | |
| shell: bash | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Make and Git | |
| run: | | |
| apt-get update && apt-get install -y make git curl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| - name: Create Python virtual environment | |
| run: | | |
| uv venv | |
| uv pip install --upgrade setuptools wheel | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install ".[test]" | |
| - name: Test with pytest | |
| run: | | |
| source .venv/bin/activate | |
| 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 without optional dependencies | |
| status: ${{ job.status }} | |
| slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | |
| tests_min_versions: | |
| name: Tests with minimum versions | |
| runs-on: | |
| group: aws-g6e-4xlarge | |
| container: | |
| image: pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel | |
| options: --gpus all | |
| defaults: | |
| run: | |
| shell: bash | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Make and Git | |
| run: | | |
| apt-get update && apt-get install -y make git curl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| - name: Create Python virtual environment | |
| run: | | |
| uv venv | |
| uv pip install --upgrade setuptools wheel | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install \ | |
| ".[dev]" \ | |
| "accelerate==1.4.0" \ | |
| "datasets==4.7.0" \ | |
| "transformers==4.56.2" | |
| - name: Test with pytest | |
| run: | | |
| source .venv/bin/activate | |
| 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 with minimum versions | |
| status: ${{ job.status }} | |
| slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} | |
| distributed_smoke: | |
| name: Distributed smoke tests | |
| runs-on: | |
| group: aws-g5-12xlarge-cache | |
| container: | |
| image: pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel | |
| options: --gpus all | |
| defaults: | |
| run: | |
| shell: bash | |
| if: github.event.pull_request.draft == false | |
| env: | |
| CUDA_VISIBLE_DEVICES: "0,1" | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Make and Git | |
| run: | | |
| apt-get update && apt-get install -y make git curl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| - name: Create Python virtual environment | |
| run: | | |
| uv venv | |
| uv pip install --upgrade setuptools wheel | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install ".[dev]" | |
| - name: Run distributed smoke tests | |
| run: | | |
| source .venv/bin/activate | |
| pytest -v tests/distributed/test_distributed.py | |
| - 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 distributed smoke tests | |
| status: ${{ job.status }} | |
| slack_token: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} |