Datasets:

Modalities:
Text
ArXiv:
llmtcl / .github /workflows /cpu-tests.yml
Maple222's picture
Add files using upload-large-folder tool
9a2816d verified
name: CPU tests
on:
push:
branches: [main]
pull_request_target:
branches: [main]
types: [opened, reopened, ready_for_review, labeled, synchronize]
pull_request: {} # todo
workflow_dispatch: {}
# lock down all permissions by default
permissions:
contents: read # needed to check out code
checks: write # needed for test results
pull-requests: read # needed for PR metadata
actions: read # needed to use actions
security-events: none
statuses: write # needed to update commit status
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request_target' }}
defaults:
run:
shell: bash
env:
HF_HOME: .cache-HF # Define HF_HOME for caching
TRANSFORMERS_CACHE: .cache-HF/transformers
DATASETS_CACHE: .cache-HF/datasets
HF_DATASETS_CACHE: .cache-HF/datasets
jobs:
testing-imports:
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request_target'
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "ubuntu-24.04", "macOS-14", "windows-2022"]
python-version: ["3.10"]
timeout-minutes: 10
steps:
- name: Checkout generic
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install minimal dependencies
run: |
pip install . -U
pip list
- name: Testing package imports
# make sure all modules are still importable with only the minimal dependencies available
run: |
modules=$(
find litgpt -type f -name "*.py" | \
sed 's/\.py$//' | sed 's/\//./g' | \
sed 's/.__init__//g' | xargs -I {} echo "import {};"
)
echo "$modules"
python -c "$modules"
pytester:
# skip PR trigger if secrets are not shared as for all forked PRs
if: |
github.event_name != 'pull_request' ||
(
github.event_name == 'pull_request' &&
contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- { os: "macOS-14", python-version: "3.9" }
- { os: "windows-2022", python-version: "3.9" }
timeout-minutes: 35
steps:
- name: Checkout generic
uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
- name: Checkout for `pull_request_target`
uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
# Add caching for HF models and tokenizers
- name: HF cache
uses: actions/cache@v4
continue-on-error: true
with:
path: .cache-HF
key: hf-cache_${{ runner.os }}-py${{ matrix.python-version }}
restore-keys: |
hf-cache_${{ runner.os }}-py${{ matrix.python-version }}
hf-cache_${{ runner.os }}-
hf-cache_
- name: Install dependencies
run: |
pip install '.[extra,compiler,test]' -U
pip list
- name: Run tests
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: pytest -v litgpt/ tests/ --timeout=180 --durations=100
- name: Show cache
run: |
pip install -q py-tree
python -m py_tree -d 1 .cache-HF
testing-guardian:
runs-on: ubuntu-latest
needs: [pytester, testing-imports]
if: |
github.event_name == 'pull_request_target' ||
(
github.event_name == 'pull_request' &&
contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
)
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90