run-tests.yaml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Tests
  2. on:
  3. push:
  4. branches: [ main ]
  5. pull_request:
  6. jobs:
  7. convert-model:
  8. runs-on: ubuntu-latest
  9. env:
  10. BLOOM_TESTING_WRITE_TOKEN: ${{ secrets.BLOOM_TESTING_WRITE_TOKEN }}
  11. timeout-minutes: 15
  12. steps:
  13. - uses: actions/checkout@v2
  14. - name: Set up Python
  15. uses: actions/setup-python@v2
  16. with:
  17. python-version: 3.9
  18. - name: Cache dependencies
  19. uses: actions/cache@v2
  20. with:
  21. path: ~/.cache/pip
  22. key: Key-v1-py3.9-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
  23. - name: Install dependencies
  24. run: |
  25. python -m pip install --upgrade pip
  26. pip install -r requirements.txt
  27. - name: Delete previous model, if exists
  28. run: |
  29. echo $(env)
  30. exit 255
  31. export HF_TAG=$(python -c "import os; print(os.environ.get('GITHUB_REF_NAME') or os.environ.get('GITHUB_BASE_REF') or 'main')")
  32. python -c "from huggingface_hub import delete_repo; delete_repo(token='$BLOOM_TESTING_WRITE_TOKEN', \
  33. name='test-bloomd-350m-$HF_TAG', organization='bloom-testing')" || true
  34. - name: Convert model and push to hub
  35. run: |
  36. export HF_TAG=$(python -c "import os; print(os.environ.get('GITHUB_BASE_REF') or os.environ.get('GITHUB_REF_NAME'))")
  37. python -m cli.convert_model --model bigscience/bloom-350m --output_path ./converted_model \
  38. --output_repo bloom-testing/test-bloomd-350m-$HF_TAG --use_auth_token $BLOOM_TESTING_WRITE_TOKEN
  39. run-tests:
  40. runs-on: ubuntu-latest
  41. needs: convert-model
  42. strategy:
  43. matrix:
  44. python-version: [ 3.7, 3.8, 3.9 ]
  45. fail-fast: false
  46. timeout-minutes: 15
  47. steps:
  48. - uses: actions/checkout@v2
  49. - name: Set up Python
  50. uses: actions/setup-python@v2
  51. with:
  52. python-version: ${{ matrix.python-version }}
  53. - name: Cache dependencies
  54. uses: actions/cache@v2
  55. with:
  56. path: ~/.cache/pip
  57. key: Key-v1-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
  58. - name: Install dependencies
  59. run: |
  60. python -m pip install --upgrade pip
  61. pip install -r requirements.txt
  62. pip install -r requirements-dev.txt
  63. - name: Test
  64. run: |
  65. export HF_TAG=$(python -c "import os; print(os.environ.get('GITHUB_REF_NAME') or os.environ.get('GITHUB_BASE_REF') or 'main')")
  66. export MODEL_NAME=bloom-testing/test-bloomd-350m-$HF_TAG
  67. export REF_NAME=bigscience/bloom-350m
  68. python -m cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 0:12 \
  69. --torch_dtype float32 --identity tests/test.id --host_maddrs /ip4/127.0.0.1/tcp/31337 --throughput 1 &
  70. SERVER1_PID=$!
  71. sleep 5 # wait for the first server to initialize DHT
  72. export INITIAL_PEERS=/ip4/127.0.0.1/tcp/31337/p2p/QmS9KwZptnVdB9FFV7uGgaTq4sEKBwcYeKZDfSpyKDUd1g
  73. # ^-- server 1 multiaddr is determined by --identity and --host_maddrs
  74. python -m cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 12:24 \
  75. --torch_dtype float32 --initial_peers $INITIAL_PEERS --throughput 1 &> server2.log &
  76. SERVER2_PID=$!
  77. sleep 30 # wait for server to download layers
  78. PYTHONPATH=. pytest tests
  79. kill -s SIGINT $SERVER1_PID $SERVER2_PID
  80. echo "Done!"