petals/.github/workflows/run-tests.yaml
justheuristic eb0a6be716
Clean up readme (#24)
Remove some deprecated sections of README and turns on CI for main branch
2022-07-16 02:11:17 +03:00

90 lines
3.3 KiB
YAML

name: Tests
on:
push:
branches: [ main ]
pull_request:
jobs:
convert-model:
runs-on: ubuntu-latest
env:
BLOOM_TESTING_WRITE_TOKEN: ${{ secrets.BLOOM_TESTING_WRITE_TOKEN }}
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: Key-v1-py3.9-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Delete previous model, if exists
run: |
python -c "from huggingface_hub import delete_repo; delete_repo(token='$BLOOM_TESTING_WRITE_TOKEN', \
name='test-bloomd-350m-$GITHUB_HEAD_REF', organization='bloom-testing')" || true
- name: Convert model and push to hub
run: |
python -m cli.convert_model --model bigscience/bloom-350m --output_path ./converted_model \
--output_repo bloom-testing/test-bloomd-350m-$GITHUB_HEAD_REF --use_auth_token $BLOOM_TESTING_WRITE_TOKEN
run-tests:
runs-on: ubuntu-latest
needs: convert-model
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9 ]
fail-fast: false
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: Key-v1-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Test
run: |
export MODEL_NAME=bloom-testing/test-bloomd-350m-$GITHUB_HEAD_REF
python -m cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 0:12 \
--torch_dtype float32 --identity tests/test.id --host_maddrs /ip4/127.0.0.1/tcp/31337 --throughput 1 &
SERVER1_PID=$!
export INITIAL_PEERS=/ip4/127.0.0.1/tcp/31337/p2p/QmS9KwZptnVdB9FFV7uGgaTq4sEKBwcYeKZDfSpyKDUd1g
# ^-- server 1 multiaddr is determined by --identity and --host_maddrs
python -m cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 12:24 \
--torch_dtype float32 --initial_peers $INITIAL_PEERS --throughput 1 &> server2.log &
SERVER2_PID=$!
sleep 30 # wait for server to download layers
# test individual blocks
export PYTHONPATH=.
BLOCK_UID=$MODEL_NAME.0 REF_NAME=$MODEL_NAME REF_INDEX=0 pytest tests/test_block_exact_match.py
BLOCK_UID=$MODEL_NAME.19 REF_NAME=$MODEL_NAME REF_INDEX=19 pytest tests/test_block_exact_match.py
REF_NAME=$MODEL_NAME pytest tests/test_chained_calls.py
REF_NAME=bigscience/bloom-350m pytest tests/test_full_model.py
kill -s SIGINT $SERVER1_PID $SERVER2_PID
echo "Done!"